/***************************************************************************
 *   Copyright (C) 2008 by mj   *
 *   hanfman_cool@web.de   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

//steamserverutil is a program to manage the steam game servers from hldsupdatetool.bin
//v0.3.0.1, last changes: 23.01.09 19:00 (only bugfixes!)



//#ifdef HAVE_CONFIG_H
//#include <config.h>
//#endif
//#include <cstdlib>

#include <iostream> //for cout and cin
#include <fstream> //for ifstream and ofstream
#include <stdlib.h> //for system()	
#include <string.h> //for strcpy, strcat and strcmp

//to make the differance of the arrays better 
#define OFF_N 0
#define OFF_C 1


using namespace std;




//version variable:
char _version [] = "v0.3.0.1";

//global variables
char param[500];	//here are the params from function choice_params() saved and the path of the server for mani admin plugin

//to test if server is currently installed (is set true when server is installed)
bool server_css, server_dods, server_garrysmod, server_hl2mp, server_tf, server_cs, server_czero, server_dmc, server_dod, server_gearbox, server_ricochet, server_tfc, server_darkmessiah, server_chivalry, server_diprip, server_insurgency, server_synergy, server_zps;

bool installed=false; //is set true when server is installed

//functions
void not_installed() {cout << "\n\nServer not installed!";}
void never_happen()  {cout << "\n\nOops steamserverutil crashed!! Please make a bug report to hanfman_cool@web.de or visit steamseverutil.googlecode.com for more information";}

//tests which server are installed
bool 	is_installed()
{
	ifstream in;
	in.open(".steamserverutil/installed_servers");
	
	if(!in.is_open())
	{
		cout << "\n\nSorry, no servers found!\nInstall one!\n\n";
		return false;
	}
	
	
	cout << "\n\nServers available: \n\n";
	
	installed=false; //set true when any server is installed

	//testing if games are installed
	
	while (!in.eof())
	{
		char temp[50];
		in.getline (temp, 50);
		
		if(!strncmp(temp, "css", 3))
		
		{
			cout << "1.  Counter Strike Source\n";
			server_css = true;
			installed = true;
		}
		
		if(!strncmp(temp, "dods", 4))

		{
			cout << "2.  Day of Defeat Source\n";
			server_dods=true;
			installed = true;
		}
	
		
		if(!strncmp(temp, "garrysmod", 9))
		{
			cout << "3.  Garrys Mod\n";
			server_garrysmod = true;
			installed = true;
		}
		
		
		if(!strncmp(temp, "hl2mp", 5))
		{
			cout << "4.  Half Life 2 Deathmatch\n";
			server_hl2mp=true;
			installed = true;
		}
	
		
		if(!strncmp(temp, "tf", 2))
		{
			cout << "5.  Team Fortress\n";
			server_tf = true;
			installed = true;
		}
		
		
		if(!strncmp(temp, "cstrike", 7))
		{
			cout << "6.  Counter Strike\n";
			server_cs=true;
			installed = true;
		}
		
		if(!strncmp(temp, "cscz", 4))
		{
			cout << "7.  Counter Strike Condition Zero\n";
			server_czero = true;
			installed = true;
		}
	
		
		if(!strncmp(temp, "dmc", 3))
		{
			cout << "8.  Deathmatch Classic\n";
			server_dmc=true;
			installed = true;
		}
				
			
		if(strncmp(temp, "dods", 4))
		{
			if(!strncmp(temp, "dod", 3))

			{
				cout << "9. Day of Defeat\n";
				server_dod = true;
				installed = true;
			}
		}
		
		
		if(!strncmp(temp, "gearbox", 7))
		{
			cout << "10. Opposing Force\n";
			server_gearbox=true;
			installed = true;
		}
	
		
		if(!strncmp(temp, "ricochet", 8))
		{
			cout << "11. Ricochet\n";
			server_ricochet = true;
			installed = true;
		}
	
		
		if(!strncmp(temp, "tfc", 3))
		{
			cout << "12. Team Fortress Classic\n";
			server_tfc=true;
			installed = true;
		}
	
		
		if(!strncmp(temp, "darkmessiah", 11))
		{
			cout << "13. Dark Messiah\n";
			server_darkmessiah=true;
			installed = true;
		}
		
		if(!strncmp(temp, "chivalry", 8))
		{
			cout << "14. Age of Chivalry\n";
			server_chivalry=true;
			installed = true;
		}
		
		if(!strncmp(temp, "diprip", 6))
		{
			cout << "15. D.I.P.R.I.P. Warm Up (HL2 Mod)\n";
			server_diprip=true;
			installed = true;
		}
		
		if(!strncmp(temp, "insurgency", 10))
		{
			cout << "16. Insurgency (HL2 Mod)\n";
			server_insurgency=true;
			installed = true;
		}
		
		if(!strncmp(temp, "synergy", 7))
		{
			cout << "17. Synergy (HL2 Mod)\n";
			server_synergy=true;
			installed = true;
		}
		
		if(!strncmp(temp, "zps", 7))
		{
			cout << "18. Zombie Panic: Source (HL2 Mod)\n";
			server_zps=true;
			installed = true;
		}
		
		
	}
	in.close();

	if(installed)
	    return true;
	else
	    return false;
}


//function which tests if the server is really installed, if it is installed it saves the path in the char param[]
void mani_test(unsigned short int choice)
{
	if (choice > 5)
	{
		cout << "\n\nServer is not supported by mani admin plugin!!\n\n";
		return;
	}
	
	if (choice == 3) //gmod
		cout << "\n\nNote that this server isn't officially supported by mani admin plugin\n";
	
	switch(choice)
	{
		case 1:	if(server_css==true)
			{
						
				strcpy(param, ".steamserverutil/servers_source/cstrike");
				installed = true;
			}
			else
			not_installed();
			break;
		case 2:	if(server_dods==true)
			{
				strcpy(param, ".steamserverutil/servers_source/dod");
											
				
				installed = true;
			}
			else
			not_installed();
			break;
		case 3:	if(server_garrysmod==true)
			{
				strcpy(param, ".steamserverutil/servers_source/garrysmod");
						
									
				installed = true;
			}
			else
			not_installed();
			break;
		case 4:	if(server_hl2mp==true)
			{
				strcpy(param, ".steamserverutil/servers_source/garrysmod");
						
									
				installed = true;
			}
			else
				not_installed();
			break;
		case 5:	if(server_tf==true)
			{	
				strcpy(param, ".steamserverutil/servers_source/tf");
					
				installed = true;
			}
			else
			not_installed();
			break;
		default: cout << "\n\nTry again ;)\n\n";
			break;
	}
}


//installs servers
void install()
{

	

	bool exit=false;

	
	
	
	ofstream out;
	out.open(".steamserverutil/installed_servers", ios_base::app);
	
	if(!out.is_open())
	{
		cout << "\n\nCreating directorys...\n";
		system("mkdir .steamserverutil/servers_source && mkdir .steamserverutil/servers_hl1");
	}
	
	while(!exit)
	{
		unsigned short int choice;
	
		
		cout << "\n\nServers available for install: \n";
		cout << "1.  Counter Strike Source\n";
		cout << "2.  Day of Defeat Source\n";
		cout << "3.  Garrys Mod\n";
		cout << "4.  Half Life 2 Deathmatch\n";
		cout << "5.  Team Fortress\n";
		cout << "6.  Counter Strike\n";
		cout << "7.  Counter Strike Condition Zero\n";
		cout << "8.  Death Match Classic\n";
		cout << "9.  Day of Defeat\n";
		cout << "10. Opposing Force\n";
		cout << "11. Ricochet\n";
		cout << "12. Team Fortress Classic\n";
		cout << "13. Dark Messiah\n";
		cout << "14. Age of Chivalry\n";
		cout << "15. D.I.P.R.I.P. Warm Up (HL2 Mod)\n";
		cout << "16. Insurgency (HL2 Mod)\n";
		cout << "17. Synergy (HL2 Mod)\n";
		cout << "18. Zombie Panic: Source (HL2 Mod)\n";
		cout << "19. EXIT to main menu\n";
		cout << " : ";
		cin >> choice;
		cin.ignore();
		
		cout << "\n\nChecking currently installed servers...";
		is_installed();


		
		switch(choice)
		{
			case 1: 	cout << "\n\nInstalling Counter Strike-Source Server...\nAdding to installed_server file\n\n";
			
					if(!server_css)
						out << "\ncss";
					system(".steamserverutil/./steam -command update -game \"Counter-Strike Source\" -dir .steamserverutil/servers_source/");
					break;
					
					
			case 2: 	cout << "\n\nInstalling Day of Defeat Source Server...\nAdding to installed_server file\n\n";
					if(!server_dods)
					out << "\ndods";
					system(".steamserverutil/./steam -command update -game \"dods\" -dir .steamserverutil/servers_source/");
					break;
					
					
			case 3: 	cout << "\n\nInstalling Garrys Mod Server...\nAdding to installed_server file\n\n";
					if(!server_garrysmod)
					out << "\ngarrysmod";
					system(".steamserverutil/./steam -command update -game \"garrysmod\" -dir .steamserverutil/servers_source/");
					break;
					
					
			case 4: 	cout << "\n\nInstalling Half Life 2 Deathmatch Server...\nAdding to installed_server file\n\n";
					if(!server_hl2mp)
					out << "\nhl2mp";
					system(".steamserverutil/./steam -command update -game \"hl2mp\" -dir .steamserverutil/servers_source/");
					break;
					
					
					
			case 5: 	cout << "\n\nInstalling Team Fortress Server...\nAdding to installed_server file\n\n";
					if(!server_tf)
					out << "\ntf";
					system(".steamserverutil/./steam -command update -game \"tf\" -dir .steamserverutil/servers_source/");
					break;
					
					
			case 6: 	cout << "\n\nInstalling Counter Strike Server...\nAdding to installed_server file\n\n";
					if(!server_cs)
					out << "\ncstrike";
					system(".steamserverutil/./steam -command update -game \"cstrike\" -dir .steamserverutil/servers_hl1/");
					break;
					
					
			case 7: 	cout << "\n\nInstalling Counter Strike Condition Zero Server...\nAdding to installed_server file\n\n";
					if(!server_czero)
					out << "\ncscz";
					system(".steamserverutil/./steam -command update -game \"czero\" -dir .steamserverutil/servers_hl1/");
					break;
					
					
			case 8: 	cout << "\n\nInstalling Death Match Classic Server...\nAdding to installed_server file\n\n";
					if(!server_dmc)
					out << "\ndmc";
					system(".steamserverutil/./steam -command update -game \"dmc\" -dir .steamserverutil/servers_hl1/");
					break;
					
					
			case 9: 	cout << "\n\nInstalling Day of Defeat Server...\nAdding to installed_server file\n\n";
					if(!server_dod)
					out << "\ndod";
					system(".steamserverutil/./steam -command update -game \"dod\" -dir .steamserverutil/servers_hl1/");
					break;
					
					
			case 10: 	cout << "\n\nInstalling Opposing Force Server...\nAdding to installed_server file\n\n";
					if(!server_gearbox)
					out << "\ngearbox";
					system(".steamserverutil/./steam -command update -game \"gearbox\" -dir .steamserverutil/servers_hl1/");
					break;
					
					
			case 11: 	cout << "\n\nInstalling Ricochet Server...\nAdding to installed_server file\n\n";
					
					if(!server_ricochet)
					out << "\nricochet";
					system(".steamserverutil/./steam -command update -game \"ricochet\" -dir .steamserverutil/servers_hl1/");
					break;
					
					
			case 12: 	cout << "\n\nInstalling Team fortress Classic Server...\nAdding to installed_server file\n\n";
					if(!server_tfc)
					out << "\ntfc";
					system(".steamserverutil/./steam -command update -game \"tfc\" -dir .steamserverutil/servers_hl1/");
					break;
					
					
			case 13: 	cout << "\n\nInstalling Dark Messiah Server...\nCreating directory...\nAdding to installed_server file\n\n";
			
					if(!out.is_open())
						system("mkdir .steamserverutil/server_darkmessiah");
					
					if(!server_darkmessiah)
					out << "\ndarkmessiah";
					system(".steamserverutil/./steam -command update -game \"darkmessiah\" -dir .steamserverutil/server_darkmessiah/");
					break;
					
					
			case 14: 	cout << "\n\nInstalling Age of Chivalry Server...\n\nAdding to installed_server file\n\n";
					if(!server_chivalry)
						out << "\nchivalry";
					system(".steamserverutil/./steam -command update -game \"ageofchivalry\" -dir .steamserverutil/servers_source/");
					break;
					
					
			case 15: 	cout << "\n\nInstalling D.I.P.R.I.P. Warm Up (HL2 Mod) Server...\nAdding to installed_server file\n\n";
					if(!server_diprip)
						out << "\ndiprip";
					system(".steamserverutil/./steam -command update -game \"diprip\" -dir .steamserverutil/servers_source/");
					break;
					
					
			case 16: 	cout << "\n\nInstalling Insurgency (HL2 Mod) Server...\nAdding to installed_server file\n\n";
					if(!server_insurgency)
						out << "\ninsurgency";
					system(".steamserverutil/./steam -command update -game \"insurgency\" -dir .steamserverutil/servers_source/");
					break;
					
					
			case 17: 	cout << "\n\nInstalling Synergy (HL2 Mod) Server...\nAdding to installed_server file\n\n";
					if(!server_synergy)
						out << "\nsynergy";
					system(".steamserverutil/./steam -command update -game \"synergy\" -dir .steamserverutil/servers_source/");
					break;
					
					
			case 18: 	cout << "\n\nInstalling Zombie Panic: Source (HL2 Mod) Server...\nAdding to installed_server file\n\n";
					if(!server_zps)
						out << "\nzps";
					system(".steamserverutil/./steam -command update -game \"zps\" -dir .steamserverutil/servers_source/");
					break;
					
					
			case 19: 	exit=true;
					break;
					
					
			default: 	cout << "\n\nTry again;)\n\n";
					break;
		}
		
		out.close();
		
	}
	
}


//adjustements for server
void param_choice()
{

	char temp[200];
	char choice;


	param[0] = 0; //0 means end of string, to avoid errors with strcat()



	cout << "\n\nDisable Valve Anti Cheat System?(y|n) ";
	cin >> choice;

	cin.ignore();

	
	if(choice == 'y')
	{
		strcat(param, "-insecure ");
	}
	
	cout <<"\n\nDisable bots?(y|n) ";
	cin >> choice;

	cin.ignore();

	if(choice == 'y')
	{
		strcat(param, "-nobots ");
	}
	
	cout << "\n\nSpecify IP?(y|n) ";
	cin >> choice;

	cin.ignore();

	if(choice == 'y')
	{
		cout <<"\n\nIP: ";
		cin.getline(temp, 100);
//		cin.ignore();

		strcat(param, "-ip ");
		strcat(param, temp);
		strcat(param, " ");
	}

	
	
	cout << "\n\nSpecify port?(y|n) ";
	cin >> choice;
	cin.ignore();

	if( choice=='y')
	{
		cout <<"\n\nPort: ";
		cin.getline(temp, 100);

		strcat(param, "-port ");
		strcat(param, temp);
		strcat(param, " ");	
	}

//	cin.ignore();

	
	cout << "\n\nMaximal Players? ";
	cin.getline(temp, 200);

	
	strcat(param, "+maxplayers ");
	strcat(param, temp);
	strcat(param, " ");

//	cin.ignore();


	cout << "\n\nWhich map? ";
	cin.getline(temp, 200);


	strcat(param, "+map ");
	strcat(param, temp);
	strcat(param, " ");

//	cin.ignore();


	cout << "\n\nOnly Lan Server?(y|n) ";
	cin >> choice;

	cin.ignore();
	
	
	if(choice=='y')
	{
		strcat(param, "+sv_lan 1 ");
	}
	
	cout << "\n\nSpecify hostname?(y|n) ";
	cin >> choice;

	cin.ignore();
	

	if (choice == 'y')
	{
		cout << "\n\nHostname: ";
		cin.getline(temp, 100);
		strcat(param, "+hostname ");
		strcat(param, temp);
	}

//	cin.ignore();
	
	
	

}


//here you can start a server
void start()
{

	char params[550];
		


	bool _installed = false;


	cout << "\n\nWhich server should be started?\n\n";
	if(!is_installed())
		return;
	unsigned short int choice;
	cout << " : ";
	cin >> choice;
	cin.ignore();
	
	strcpy(params, "cd .steamserverutil/");
	
	cout << "\n\nWhen you have \"screen\" installed, you can start a server in background, independent of the steamserverutil session.\n";
	cout << "Start the server in background with screen?(y|n) ";
	char screen;
	cin >> screen;

	switch(choice)
	{
		case 1:	if(server_css==true)
				{
					
					
					_installed = true;
					
					if(screen != 'y')
					strcat(params, "servers_source && ./srcds_run -game cstrike ");
					else
					strcat(params, "servers_source && screen -A -m -d -S css ./srcds_run -game cstrike ");
					

				}
				else
				not_installed();
				break;
		case 2:	if(server_dods==true)
				{
					
					_installed = true;
					if(screen != 'y')
					strcat(params, "servers_source && ./srcds_run -game dod ");
					else
						strcat(params, "servers_source && screen -A -m -d -S dods ./srcds_run -game dod ");
		
			
			
				
					
				}
				else
				not_installed();
				break;

		case 3:	if(server_garrysmod==true)
				{
					_installed = true;
					if(screen != 'y')
					strcat(params, "servers_source && ./srcds_run -game garrysmod ");
				
					else
						strcat(params, "servers_source && screen -A -m -d -S garrysmod ./srcds_run -game garrysmod ");
	
			
					
				}
				else
				not_installed();
				break;
		case 4:	if(server_hl2mp==true)
				{
					_installed = true;
					if(screen != 'y')
					strcat(params, "servers_source && ./srcds_run -game hl2mp ");
					else
						strcat(params, "servers_source && screen -A -m -d -S hl2mp ./srcds_run -game hl2mp ");

	
				
					
				}
				else
				not_installed();
				break;
		case 5:	if(server_tf==true)
				{	
					_installed = true;
					if(screen != 'y')
					strcat(params, "servers_source && ./srcds_run -game tf");
					else
						strcat(params, "servers_source && screen -A -m -d -S tf ./srcds_run -game zf ");

				}
				else
				not_installed();
				break;
		case 6:	if(server_cs==true)
				{
					_installed = true;
					if(screen != 'y')
					strcat(params, "servers_hl1 && ./hlds_run -game cstrike ");
			
					else
						strcat(params, "servers_hl1 && screen -A -m -d -S cstrike ./srcds_run -game cstrike ");
				

			
					
				}
				else
				not_installed();
				break;
		case 7:	if(server_czero==true)
				{
					_installed = true;
					if(screen != 'y')
					strcat(params, "servers_hl1 && ./hlds_run -game czero ");
			

					else
						strcat(params, "servers_hl1 && screen -A -m -d -S czero ./srcds_run -game czero ");

			
					
				}
				else
				not_installed();
				break;
		case 8:	if(server_dmc==true)
				{
					_installed = true;
					if(screen != 'y')
					strcat(params, "servers_hl1 && ./hlds_run -game dmc ");
					

				
					else
						strcat(params, "servers_hl1 && screen -A -m -d -S dmc ./srcds_run -game dmc ");
					
				}
				else
				not_installed();
				break;
		case 9:	if(server_dod==true)
				{
					_installed = true;
					if(screen != 'y')
					strcat(params, "servers_hl1 && ./hlds_run -game dod");
				

					else
						strcat(params, "servers_hl1 && screen -A -m -d -S dod ./srcds_run -game dod ");
		
					
				}
				else
				not_installed();
				break;
		case 10:	if(server_gearbox==true)
				{
					_installed = true;
					
					if(screen != 'y')
					strcat(params, "servers_hl1 && ./hlds_run -game gearbox");
				

			
					else
						strcat(params, "servers_hl1 && screen -A -m -d -S gearbox ./srcds_run -game gearbox ");
				
			
				
				}
				else
				not_installed();
				break;
		case 11:	if(server_ricochet==true)
				{
					_installed = true;
					
					if(screen != 'y')
					strcat(params, "servers_hl1 && ./hlds_run -game ricochet");
			

			
		
					else
						strcat(params, "servers_hl1 && screen -A -m -d -S ricochet ./srcds_run -game ricochet ");
			
				}
				else
				not_installed();
				break;
		case 12:	if(server_tfc==true)
				{
					_installed = true;
					
					if(screen != 'y')
					strcat(params, "servers_hl1 && ./hlds_run -game tfc");
					
					else
						strcat(params, "servers_hl1 && screen -A -m -d -S tfc ./srcds_run -game tfc ");
			
					
			
				}
				else
				not_installed();
				break;
		case 13:	if(server_darkmessiah==true)
				{
					_installed = true;

					if(screen != 'y')
					strcat(params, "server_darkmessiah && ./srcds_run ");
					

					else
						strcat(params, "server_darkmessiah && screen -A -m -d -S darkmessiah ./srcds_run ");
					
			
			
				}
				else
				not_installed();
				break;
				
		case 14:	if(server_chivalry==true)
				{
					_installed = true;

					if(screen != 'y')
						strcat(params, "server_source && ./srcds_run -agme ageofchivalry ");
					

					else
						strcat(params, "server_darkmessiah && screen -A -m -d -S chivalry ./srcds_run -game ageofchivalry ");
					
			
			
				}
				else
					not_installed();
				break;
				
		case 15:	if(server_diprip==true)
				{
					
					
					_installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game diprip ");
					else
						strcat(params, "servers_source && screen -A -m -d -S diprip ./srcds_run -game diprip ");
					

				}
				else
					not_installed();
				break;
		case 16:	if(server_css==true)
				{
					
					
					_installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game insurgency ");
					else
						strcat(params, "servers_source && screen -A -m -d -S insurgency ./srcds_run -game insurgency ");
					

				}
				else
					not_installed();
				break;
		case 17:	if(server_synergy==true)
				{
					
					
					_installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game synergy ");
					else
						strcat(params, "servers_source && screen -A -m -d -S synergy ./srcds_run -game synergy ");
					

				}
				else
					not_installed();
				break;
		case 18:	if(server_zps==true)
				{
					
					
					_installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game zps ");
					else
						strcat(params, "servers_source && screen -A -m -d -S zps ./srcds_run -game zps ");
					

				}
				else
					not_installed();
				break;
		default: cout << "\n\nWrong choice! Try again ;)\n\n";
				break;
	}
	
	
	if( _installed == true)
	{	
		param_choice();
		strcat(params, param);
		strcat(params, " +exec server.cfg");
		
		
	
		//here the server starts
	
		cout << "\nStarting the server...";
		
		cout << flush; //the message should come before the server starts ;)
		
		system(params);
	}
}


//here you can adjust and start your favorites


void favorites()
{

	char input[100][2][550];


	int j;
	
	

	
	bool exit = false;
	
	//read .steamserverutil/favorites and save entrys in variables
	while(!exit)
	{


		j=-1;	

		ifstream in;
		in.open(".steamserverutil/favorites");
		cout << "\n\nReading favorites...\n\n";
	
		if(in.is_open())
		{

			char temp[550];
				
	

	
			while(!in.eof())
			{
	
				
				
				in.getline(temp, 550);
	
				switch(temp[0])
				{
					case 'n': if(temp[1] == ':')
						  {
							j++;
							strcpy(input[j][OFF_N], &(temp[3]));
							
						  }
						 else
						 cout << "Your .favorites is incorrupt, cannot understand: " << temp << "\nIgnoring...\n";
						break;
					case 'c': if(temp[1] == ':')
						  {
							strcpy(input[j][OFF_C], &(temp[3]));
						  }
						 else
						 cout << "Your .favorites is incorrupt, cannot understand: " << temp << "\nIgnoring...\n";
						 break;
					default: if(temp[0] == 10 || temp[0]== 0) //10 means new line 0 means end of string
						 {
							//nothing to do
						 }
						 else
						 cout << "Your .favorites is incorrupt, cannot understand: " << temp << "\nIgnoring...\n";
						break;
				}
				
				if(j > 100)
				{
					never_happen();
					cout << "\nToo many favorites (>100)\n";
					break;
				}
			}
	
			
			
		}
		else
		{
			cout << "You have no favorites, please add one!\n\n";
		}
	
		in.close();
		







		//reading is finished, now user can adjust favorites
		unsigned short int choice;
		char params[(sizeof("cd server_tshb && ./srcds_run ") + 500)];
		char name[100];
		
		bool installed = false; //is set true when server is installed

		ofstream save;
		save.open(".steamserverutil/favorites", ios_base::app);
		
		cout << "\n\n1. Add favorite\n";
		cout << "2. Delete favorite\n";
		cout << "3. Delete all favorites\n";
		cout << "4. Start favorite\n";
		cout << "5. Back to main menu\n";
		cout << " : ";
		cin >> choice;

		

		switch(choice)
		{
			

			case 1: cout << "\n\nFrom which game should be the favorite?\n\n";


			if(!is_installed())
				return;
			unsigned short int choice;
			cout << " : ";
			cin >> choice;
			cin.ignore();
	
			strcpy(params, "cd .steamserverutil/");
	
			cout << "\n\nWhen you have \"screen\" installed, you can start a server in background, independent of the steamserverutil session.\n";
			cout << "Start the server in background with screen?(y|n) ";
			char screen;
			cin >> screen;

			switch(choice)
			{
				case 1:	if(server_css==true)
				{
					
					
					installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game cstrike ");
					else
						strcat(params, "servers_source && screen -A -m -d -S css ./srcds_run -game cstrike ");
					

				}
				else
					not_installed();
				break;
				case 2:	if(server_dods==true)
				{
					
					installed = true;
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game dod ");
					else
						strcat(params, "servers_source && screen -A -m -d -S dods ./srcds_run -game dod ");
		
			
			
				
					
				}
				else
					not_installed();
				break;

				case 3:	if(server_garrysmod==true)
				{
					installed = true;
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game garrysmod ");
				
					else
						strcat(params, "servers_source && screen -A -m -d -S garrysmod ./srcds_run -game garrysmod ");
	
			
					
				}
				else
					not_installed();
				break;
				case 4:	if(server_hl2mp==true)
				{
					installed = true;
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game hl2mp ");
					else
						strcat(params, "servers_source && screen -A -m -d -S hl2mp ./srcds_run -game hl2mp ");

	
				
					
				}
				else
					not_installed();
				break;
				case 5:	if(server_tf==true)
				{	
					installed = true;
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game tf");
					else
						strcat(params, "servers_source && screen -A -m -d -S tf ./srcds_run -game zf ");

				}
				else
					not_installed();
				break;
				case 6:	if(server_cs==true)
				{
					installed = true;
					if(screen != 'y')
						strcat(params, "servers_hl1 && ./hlds_run -game cstrike ");
			
					else
						strcat(params, "servers_hl1 && screen -A -m -d -S cstrike ./srcds_run -game cstrike ");
				

			
					
				}
				else
					not_installed();
				break;
				case 7:	if(server_czero==true)
				{
					installed = true;
					if(screen != 'y')
						strcat(params, "servers_hl1 && ./hlds_run -game czero ");
			

					else
						strcat(params, "servers_hl1 && screen -A -m -d -S czero ./srcds_run -game czero ");

			
					
				}
				else
					not_installed();
				break;
				case 8:	if(server_dmc==true)
				{
					installed = true;
					if(screen != 'y')
						strcat(params, "servers_hl1 && ./hlds_run -game dmc ");
					

				
					else
						strcat(params, "servers_hl1 && screen -A -m -d -S dmc ./srcds_run -game dmc ");
					
				}
				else
					not_installed();
				break;
				case 9:	if(server_dod==true)
				{
					installed = true;
					if(screen != 'y')
						strcat(params, "servers_hl1 && ./hlds_run -game dod");
				

					else
						strcat(params, "servers_hl1 && screen -A -m -d -S dod ./srcds_run -game dod ");
		
					
				}
				else
					not_installed();
				break;
				case 10:	if(server_gearbox==true)
				{
					installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_hl1 && ./hlds_run -game gearbox");
				

			
					else
						strcat(params, "servers_hl1 && screen -A -m -d -S gearbox ./srcds_run -game gearbox ");
				
			
				
				}
				else
					not_installed();
				break;
				case 11:	if(server_ricochet==true)
				{
					installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_hl1 && ./hlds_run -game ricochet");
			

			
		
					else
						strcat(params, "servers_hl1 && screen -A -m -d -S ricochet ./srcds_run -game ricochet ");
			
				}
				else
					not_installed();
				break;
				case 12:	if(server_tfc==true)
				{
					installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_hl1 && ./hlds_run -game tfc");
					
					else
						strcat(params, "servers_hl1 && screen -A -m -d -S tfc ./srcds_run -game tfc ");
			
					
			
				}
				else
					not_installed();
				break;
				case 13:	if(server_darkmessiah==true)
				{
					installed = true;

					if(screen != 'y')
						strcat(params, "server_darkmessiah && ./srcds_run ");
					

					else
						strcat(params, "server_darkmessiah && screen -A -m -d -S darkmessiah ./srcds_run ");
					
			
			
				}
				else
					not_installed();
				break;
				
				case 14:	if(server_chivalry==true)
				{
					installed = true;

					if(screen != 'y')
						strcat(params, "server_source && ./srcds_run -agme ageofchivalry ");
					

					else
						strcat(params, "server_darkmessiah && screen -A -m -d -S chivalry ./srcds_run -game ageofchivalry ");
					
			
			
				}
				else
					not_installed();
				break;
				
				case 15:	if(server_diprip==true)
				{
					
					
					installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game diprip ");
					else
						strcat(params, "servers_source && screen -A -m -d -S diprip ./srcds_run -game diprip ");
					

				}
				else
					not_installed();
				break;
				case 16:	if(server_css==true)
				{
					
					
					installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game insurgency ");
					else
						strcat(params, "servers_source && screen -A -m -d -S insurgency ./srcds_run -game insurgency ");
					

				}
				else
					not_installed();
				break;
				case 17:	if(server_synergy==true)
				{
					
					
					installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game synergy ");
					else
						strcat(params, "servers_source && screen -A -m -d -S synergy ./srcds_run -game synergy ");
					

				}
				else
					not_installed();
				break;
				case 18:	if(server_zps==true)
				{
					
					
					installed = true;
					
					if(screen != 'y')
						strcat(params, "servers_source && ./srcds_run -game zps ");
					else
						strcat(params, "servers_source && screen -A -m -d -S zps ./srcds_run -game zps ");
					

				}
				else
					not_installed();
				break;
				default: cout << "\n\nWrong choice, Try again ;)\n\n";
				break;
				
			}
					

					

					if(installed==true)
					{
						cout << "\n\nNow you should make a few adjustments for the favorite\n\n";
	
						param_choice();

						strcat(params, param);
					
						cout << "\n\nWhich name do you wish for this favorite? ";
						cin.getline(name, 100);

						//cin.ignore();

						save << "n: " << name << endl;
						save << "c: " << params << endl;
						save.close();
					}

					break;


			case 2: cout << "\n\nWhich favorite server do you want to delete?\n\n";
				for (int i = 0; i<=j;i++)
				{
					cout << (i+1) << "\t" <<  input[i][OFF_N] << endl;
				}
				
				cout << " : ";
				cin >> choice;
				
				choice--;


				if(choice > j)
				{
					cout << "\n\nThis entry does not exist!";
				}
				else
				{

					ofstream save_del;
					save_del.open(".steamserverutil/favorites");




					for (int i = 0;i<=j;i++)
					{

						
						if(i==choice)
						{
							//nothing to do
						}
						else
						{
							save_del << "n: " << input[i][OFF_N] << endl;
							save_del << "c: " << input[i][OFF_C] << endl;
						}
							
					}
					save_del.close();
				}
				break;

			case 3: char temp;
				cout << "\n\nAll favorites are going to be deleted. Are you sure?(y|n) ";
				cin >> temp;
				

				if(temp=='y')
				{
					ofstream del_all;
					del_all.open(".steamserverutil/favorites");
					del_all.close();
				}
				break;
			case 4: cout << "\n\nWhich favorite server do you want to start?\n\n";
				for (int i = 0; i<=j;i++)
				{
					cout << (i+1) << "\t" <<  input[i][OFF_N] << endl;
				}
				
				cout << " : ";
				cin >> choice;

				choice--;
				
				if(choice > j)
				{
					cout << "\n\nThis entry does not exist!";
					break;
				}
				else
				{	
					cout << "\n\nStarting favorite...";	
					
					cout << flush; //the message should come before the server starts ;)
		
					system(input[choice][OFF_C]);
				}
				break;
			case 5: exit=true;
				break;
			default: cout << "\n\nTry again ;)\n";
		} 
		

	save.close();
	
	}
	
}

void copy_maps()
{
	
	char params[550]; //here is saved the complete cp command
	
	cout << "\n\nInto which server do you want to copy the maps?";

	if(!is_installed())
		return;


	

	unsigned short int choice;
	cout << " : ";
	cin >> choice;
	cin.ignore();

	bool installed=false; //is set true when server is installed

	
	strcpy(params, "cd .steamserverutil/");

	

	switch(choice)
	{
		case 1:	if(server_css==true)
			{
						
				strcat(params, "servers_source/cstrike && ");
				installed = true;
			}
			else
			not_installed();
			break;
		case 2:	if(server_dods==true)
			{
				strcat(params, "servers_source/dod && ");
											
				
				installed = true;
			}
			else
			not_installed();
			break;
		case 3:	if(server_garrysmod==true)
			{
				strcat(params, "servers_source/garrysmod && ");
									
					
				installed = true;
			}
			else
			not_installed();
			break;
		case 4:	if(server_hl2mp==true)
			{
				strcat(params, "servers_source/hl2mp && ");
						
									
				installed = true;
			}
			else
			not_installed();
			break;
		case 5:	if(server_tf==true)
			{	
				strcat(params, "servers_source/tf && ");
					
				installed = true;
			}
			else
			not_installed();
			break;
		case 6:	if(server_cs==true)
			{
				strcat(params, "servers_hl1/cstrike && ");
									
									
				installed = true;
			}
			else
			not_installed();
			break;
		case 7:	if(server_czero==true)
			{
				strcat(params, "servers_hl1/czero && ");
							
									
				installed = true;
			}
			else
			not_installed();
			break;
		case 8:	if(server_dmc==true)
			{
				strcat(params, "servers_hl1/dmc && ");
				
						
				installed = true;
			}
			else
			not_installed();
			break;
		case 9:	if(server_dod==true)
				{
					strcat(params, "servers_hl1/dod && ");
								
					
					installed = true;
				}
				else
				not_installed();
				break;
		case 10:	if(server_gearbox==true)
				{
					strcat(params, "servers_hl1/gearbox && ");
									
			
					installed = true;
				}
				else
				not_installed();
				break;
		case 11:	if(server_ricochet==true)
				{
					strcat(params, "servers_hl1/ricochet && ");
									
			
					installed = true;
				}
				else
				not_installed();
				break;
		case 12:	if(server_tfc==true)
				{
					strcat(params, "servers_hl1/tfc && ");
									
			
					installed = true;
				}
				else
				not_installed();
				break;
		case 13:	if(server_darkmessiah==true)
				{

					strcat(params, "server_darkmessiah && ");
									
					installed = true;
			
				}
				else
				not_installed();
				break;
		case 14:	if(server_chivalry==true)
				{

					strcat(params, "servers_source/ageofchivalry && ");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		case 15:	if(server_diprip==true)
				{

					strcat(params, "servers_source/diprip && ");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		case 16:	if(server_insurgency==true)
				{

					strcat(params, "servers_source/insurgency && ");
									
					installed = true;
			
				}
				else
					not_installed();
		case 17:	if(server_synergy==true)
				{

					strcat(params, "servers_source/sunergy && ");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		case 18:	if(server_zps==true)
				{

					strcat(params, "servers_source/zps && ");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		default: cout << "\n\nTry again ;)\n\n";
			break;
	}
					

					

	if(installed==true)
	{
		char temp[530];
		
		cout << "\n\nWhere are the maps? ";
		cin.getline(temp, 500);

		strcat(params, "cp -v ");
		strcat(params, temp);
		strcat(params, "/* maps/ ");

		system(params);
		
		//cin.ignore();

		
	}
	
}

void edit_mapcl(int x)
{
	//x=1 to edit maplist.txt
	//x=2 to edit mapcycle.txt
	//x=3 to edit votemaplist.txt (only with mani admin plugin)



	char params[200];

	cout << "\n\nFrom which server do you want to edit the ";
	if(x==1)
	cout << "maplist?";
	if(x==2)
	cout << "mapcycle?";
	if(x==3)
	cout << "votemaplist.txt?";


	if(!is_installed())
		return;


	

	unsigned short int choice;
	cout << " : ";
	cin >> choice;
	cin.ignore();

	bool installed=false; //is set true when server is installed
	
	
	strcpy(params, ".steamserverutil/");


	

	switch(choice)
	{
		case 1:	if(server_css==true)
			{
						
				strcat(params, "servers_source/cstrike");
				installed = true;
			}
			else
			not_installed();
			break;
		case 2:	if(server_dods==true)
			{
				strcat(params, "servers_source/dod");
											
				
				installed = true;
			}
			else
			not_installed();
			break;
		case 3:	if(server_garrysmod==true)
			{
				strcat(params, "servers_source/garrysmod");
									
					
				installed = true;
			}
			else
			not_installed();
			break;
		case 4:	if(server_hl2mp==true)
			{
				strcat(params, "servers_source/hl2mp");
						
									
				installed = true;
			}
			else
			not_installed();
			break;
		case 5:	if(server_tf==true)
			{	
				strcat(params, "servers_source/tf");
					
				installed = true;
			}
			else
			not_installed();
			break;
		case 6:	if(server_cs==true)
			{
				strcat(params, "servers_hl1/cstrike");
									
									
				installed = true;
			}
			else
			not_installed();
			break;
		case 7:	if(server_czero==true)
			{
				strcat(params, "servers_hl1/czero");
							
									
				installed = true;
			}
			else
			not_installed();
			break;
		case 8:	if(server_dmc==true)
			{
				strcat(params, "servers_hl1/dmc");
				
						
				installed = true;
			}
			else
			not_installed();
			break;
		case 9:	if(server_dod==true)
				{
					strcat(params, "servers_hl1/dod");
								
					
					installed = true;
				}
				else
				not_installed();
				break;
		case 10:	if(server_gearbox==true)
				{
					strcat(params, "servers_hl1/gearbox");
									
			
					installed = true;
				}
				else
				not_installed();
				break;
		case 11:	if(server_ricochet==true)
				{
					strcat(params, "servers_hl1/ricochet");
									
			
					installed = true;
				}
				else
				not_installed();
				break;
		case 12:	if(server_tfc==true)
				{
					strcat(params, "servers_hl1/tfc");
									
			
					installed = true;
				}
				else
				not_installed();
				break;
		case 13:	if(server_darkmessiah==true)
				{

					strcat(params, "server_darkmessiah");
									
					installed = true;
			
				}
				else
				not_installed();
				break;
		case 14:	if(server_chivalry==true)
				{

					strcat(params, "cd servers_source/ageofchivalry");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		case 15:	if(server_diprip==true)
				{

					strcat(params, "cd servers_source/diprip");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		case 16:	if(server_insurgency==true)
				{

					strcat(params, "cd servers_source/insurgency");
									
					installed = true;
			
				}
				else
					not_installed();
		case 17:	if(server_synergy==true)
				{

					strcat(params, "cd servers_source/sunergy");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		case 18:	if(server_zps==true)
				{

					strcat(params, "cd servers_source/zps");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		default: cout << "\n\nTry again ;)\n\n";
			break;
	}




	if(installed==true)
	{

		char mapfolder[70];


		
		strcpy(mapfolder, params);
		strcat(mapfolder, "/maps/");

		if (x==1)
		{
			strcat(params, "/maplist.txt");
	
		}
		if(x==2)
		{
			strcat(params, "/mapcycle.txt");
	
		}
		if(x==3)
		{
			strcat(params, "/cfg/mani_admin_plugin/votemaplist.txt");
		}







		bool exit =false;
			
		while(!exit)
		{
	
			if((x !=1) && (x !=2) && x !=3)
			{
				never_happen();
				break;
			}


			if (x==1)
			{
				cout << "\n\nHere is your current maplist: \n\n";
			}
			if(x==2)
			{
		
				cout << "\n\nHere is your current mapcycle: \n\n";
			}
			if(x==3)
			{
				cout << "\n\nHere is your current votemaplist: \n\n";
			}



	
			//x=1 to edit maplist.txt
			//x=2 to edit mapcycle.txt
			//x=3 to edit votemaplist.txt (only with mani admin plugin)

		
			
	
			ifstream input; //to read current *.txt
			input.open(params);

			ofstream output; //to add a new entry
			output.open(params, ios_base::app);


			char maps[350][50];
			unsigned int i;

			i=0;

			if(input.is_open())
			{	
				while(!input.eof())
				{
			
				
					input.getline(maps[i], 50);

					if(maps[i][0] == 10 || maps[i][0] == 0) //10 means new line, 0 means end of string
					{
						//nothing to do
					}
					else
					{
						cout << (i+1) << ".\t" << maps[i] << endl;
						i++;
					}
				}
			}
			else
			{
				cout << "\nNo maps. Please add one\n";
			
			}	
			input.close();





		
			unsigned short int choice;
			
			cout << "\n\n1. Add a map\n";
			cout << "2. Delete a map\n";
			cout << "3. Copy all maps from map folder\n";
			cout << "4. Delete all maps\n";
			cout << "5. Back \n";
			cout << " : ";

			cin >> choice;

			cin.ignore();


			

			char temp[200];
	
			switch(choice)
			{
				case 1: cout << "\n\nName of map? ";
					cin.getline(temp, 50);

					output << endl << temp;
					break;

				case 2: cout << "\n\nWhich map do you wish to delete? ";
					unsigned int choice;

					cin >> choice;
					choice--;
					
					if (choice >= i)
					{
						cout << "\n\nThis entry does not exist!\n";
					}
					else
					{
						ofstream save_del;
						save_del.open(params);

						for (int y = 0; y<i; y++)
						{
							if(y==choice)
							{
								//nothing to do
							}
							else
							{
								save_del << maps[y] << endl;
							}
						}
						save_del.close();
					}
					break;

				case 3: 
					char map[100];

					map[0]='^'; // to avoid errors with strncmp()
					map[1]=0;

					strcpy(temp, "ls -1 ");
					strcat(temp, mapfolder);
					strcat(temp, " > temp.txt");

					system(temp);

					
					{
						ifstream in_temp;
						in_temp.open("temp.txt");

						ofstream out;
						out.open(params);
						
						if(in_temp.is_open())
						{
							while(!in_temp.eof())
							{
								char temp[100];
								
								in_temp.getline(temp, 200);


								if(!strncmp(temp, map, strlen(map)))
								{
									continue;
								}

								if(!strcmp(temp, "materials"))
								{
									continue;
								}
					
								if(!strcmp(temp, "graphs"))
								{
									continue;
								}

								if(!strcmp(temp, "soundcache"))
								{
									continue;
								}



								for(int i=0; i <= strlen(temp); i++)
								{
									int k = 0;
									switch(temp[i])
									{
										case '.': k=1; 
											  break;
										default: map[i]=temp[i];
											break;
									}
									if(k==1)
									{
										map[i]=0; //0 means end of string
										break;
									}
								}
								out << map << endl;
							}
						}
						else
						{
							never_happen();
							cout << "Cannot open temp.txt";
						}

						in_temp.close();
						out.close();
					}


					
					system("rm -rf temp.txt");

					break;

					
				case 4: char tempi;
					cout << "\n\nAll the maps are going to be deleted. Are you sure?(y|n) ";
					cin >> tempi;
				

					if(tempi=='y')
					{
						ofstream del_all;
						del_all.open(params);
						del_all.close();
					}
					break;
				case 5: exit=true;
					
					break;
				
				default: cout << "\n\nWrong choice. Try again ;)";
					 break;
			}


			
			output.close(); //closing file to add a new entry
			
		}
	



	}



}

void install_mani()
{
	cout << "\n\nIn which server do you want to install mani admin plugin?\n\n";

	unsigned int choice;

	if(!is_installed())	
	return;

	cout << "\n : ";

	char params[300]; //the hole command is saved here

	cin >> choice;
	cin.ignore();



	strcpy (params, "cd "); //because in function mani_test the "cd " is not included

	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcat(params, param);
	//-------end---------(modified)


	if(installed==true)
	{
		if (choice==5)
		{
			
			cout << endl << endl << "Downloading mani admin plugin with wget, unzipping archive..." << endl << endl;
			strcat (params, " && wget http://steamserverutil.googlecode.com/files/mani_admin_plugin_v1_2_beta_s_orange.zip && ");

			//to download mani admin plugin


			strcat(params, "unzip -o mani_admin_plugin_v1_2_beta_s_orange.zip ");
			//to unzip mani amdin plugin (unzips automatically in right folder)

			system(params);
		}
		else
		{
			cout << endl << endl << "Downloading mani admin plugin with wget, unzipping archive..." << endl << endl;
			strcat (params, " && wget http://steamserverutil.googlecode.com/files/mani_admin_plugin_v1_2_beta_s.zip && ");

			//to download mani admin plugin



			strcat(params, "unzip -o mani_admin_plugin_v1_2_beta_s.zip ");
			//to unzip mani amdin plugin (unzips automatically in right folder)

			system(params);

		}



		ofstream save_vdf;

		cout << "\n\nCreating mani_admin_plugin.vdf\n";

		switch (choice)
		{

			case 1: 
				save_vdf.open(".steamserverutil/servers_source/cstrike/addons/mani_admin_plugin.vdf");
				
				save_vdf << "\"Plugin\"\n";
				save_vdf << "{\n";
				save_vdf << " \"file\" \"../cstrike/addons/mani_admin_plugin\"\n";
				save_vdf << "}";
				break;

			case 2: 
				save_vdf.open(".steamserverutil/servers_source/dod/addons/mani_admin_plugin.vdf");
				
				save_vdf << "\"Plugin\"\n";
				save_vdf << "{\n";
				save_vdf << " \"file\" \"../dod/addons/mani_admin_plugin\"\n";
				save_vdf << "}";
				break;
				
			case 3: 
				save_vdf.open(".steamserverutil/servers_source/garrysmod/addons/mani_admin_plugin.vdf");
				
				save_vdf << "\"Plugin\"\n";
				save_vdf << "{\n";
				save_vdf << " \"file\" \"../garrysmod/addons/mani_admin_plugin\"\n";
				save_vdf << "}";
				
				save_vdf.close();
				save_vdf.open(".steamserverutil/servers_source/garrysmod/cfg/server.cfg", ios_base::app);
				
				save_vdf << "\n\nexec mani_server\n";
				break;

			case 4: 
				save_vdf.open(".steamserverutil/servers_source/hl2mp/addons/mani_admin_plugin.vdf");
				
				save_vdf << "\"Plugin\"\n";
				save_vdf << "{\n";
				save_vdf << " \"file\" \"../hl2mp/addons/mani_admin_plugin\"\n";
				save_vdf << "}";
				break;

			case 5:
				save_vdf.open(".steamserverutil/servers_source/tf/addons/mani_admin_plugin.vdf");
				
				save_vdf << "\"Plugin\"\n";
				save_vdf << "{\n";
				save_vdf << " \"file\" \"../tf/addons/mani_admin_plugin\"\n";
				save_vdf << "}"; 
				break;



			default: never_happen();
				 break;

		}
		
		save_vdf.close();


		cout << "\n\nMani Admin Plugin succesfully installed!\n";
			
	}
}

void install_quake()
{
	cout << "\n\nIn which server do you want to install the quake sound pack?\n\n";

	unsigned int choice;

	if(!is_installed())	
		return;

	cout << "\n : ";

	char params[300]; //the hole command is saved here

	cin >> choice;
	cin.ignore();



	strcpy (params, "cd "); //because in function mani_test the "cd " is not included

	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcat(params, param);
	//-------end---------(modified)
	
	//we dont need this, because the line is always in mani_server.cfg
	//char cfg_dir[200];
	//strcpy(cfg_dir ,param); //to add the required line to mani_server.cfg


	if(installed==true)
	{
		
			
			cout << endl << endl << "Downloading quake sound pack with wget, unzipping archive..." << endl << endl;
			strcat (params, " && wget http://steamserverutil.googlecode.com/files/quake_pack.zip && ");

			//to download mani admin plugin


			strcat(params, "unzip -o quake_pack.zip ");
			//to unzip mani amdin plugin (unzips automatically in right folder)
			
			system(params);
			
			cout << "\n\nquake sound pack succesfully installed!\n\n";

	}	
	
}

void deactivate_mani()
{
	cout << "\n\nForm which server do you wish to deactivate the mani admin plugin? \n";
	
	if(!is_installed())
	return;

	unsigned short int choice;
	cout << "\n : ";
	
	cin >> choice;

	char params[100];


	strcpy(params, "cd "); //the "cd " is not include by mani_test(int)
	
	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcat(params, param);
	//-------end---------(modified)


	

	if(installed==true)
	{
		cout << "\n\nDeactivating mani admin plugin...\nDeleting mani_admin_plugin.vdf";
		strcat(params, " && rm -rf addons/mani_admin_plugin.vdf");


		system(params);
	}


}


void mani_admins()
{
	bool exit = false;


	char params[100];

	cout << "\n\nFrom which server do you want to manage the admins?\n";

	if(!is_installed())
	return;

	unsigned short int choice;
	cout << "\n : ";
	cin >> choice;

	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcpy(params, param);
	//-------end---------

	if(installed==true)
	{

		//copy old adminlist to the new one!
		char temp[200];
		strcpy(temp, "cd ");
		strcat(temp, params);
		strcat(temp, " && ");
		strcat(temp, "cp cfg/mani_admin_plugin/adminlist.txt.old cfg/mani_admin_plugin/adminlist.txt");
		system(temp);

		strcat(params, "/cfg/mani_admin_plugin/adminlist.txt");

		cout << endl << endl;

		while (!exit)
		{


			char input[50][2][200]; //OFF_N = 0 means name; OFF_C = 1 means steam id or ip
			
			ifstream in;
			in.open(params);


			int counter = 0;

			if(in.is_open())
			{

				cout << "\n\nCurrent admins: \n";
				
				while(!in.eof())
				{
					char temp[200];

					in.getline(temp, 200);


				
					switch(temp[0])
					{
						case 'S': if(!strncmp(temp, "STEAM", 5))
							  {
								strcpy(input[counter][OFF_C], temp);
							  }
							  else
							   cout << "\n\nCannot understand: " << temp << "\nIgnoring...";

							  break;
						
						case ';': strcpy(input[counter][OFF_C], temp);
							  break;
						case '/': if(!strncmp(temp, "//n: ", 5))
							  {
								strcpy(input[counter][OFF_N], &temp[5]);
								cout << (counter+1) << ".\t" << input[counter][OFF_N] << endl;
								counter++;
							  }
							  break;
						default: 
							if(temp[0] == 10 || temp[0]== 0) //10 means new line 0 means end of string
							 {
								//nothing to do
							 }
						 	 else
						 	 cout << "\n\nCannot understand: " << temp << "\nIgnoring...";
					}
				}
			}
			else
			{
				cout << "\nNo admins. Please add one\n";
			
			}
			in.close();


			cout << "\n\n1. Add admin\n";
			cout << "2. Delete admin\n";
			cout << "3. Delte all admins\n";
			cout << "4. Exit\n";
			cout << " : ";

			cin >> choice;
			cin.ignore();


			char temp[200];

			ofstream out;
			out.open(params, ios_base::app);

			switch(choice)
			{
				case 1: 
					
					cout << "\n\nSteam ID or IP of the player? ";
					cin.getline(temp, 200);
					
					//test if steam id or ip
					if(!strncmp(temp, "STEAM", 5))
					{
						out << endl << temp << endl;
					}
					else
					{
						out << endl<< ";"<< temp << endl;
					}


					cout << "\nName or steam account of the player? ";
					cin.getline(temp, 200);
					out << "//n: " << temp;
					break;
				case 2: cout << "\n\nWhich admin do you want do delete? ";
					cin >> choice;
		
					choice--;

					if(choice >= counter)
					{
						cout << "\nThis entry does not exist!\n\n";
					}
					else
					{

						ofstream save_del;
						save_del.open(params);




						for (int i = 0;i<counter;i++)
						{

						
							if(i==choice)
							{
								//nothing to do
							}
							else
							{
								save_del << endl << input[i][OFF_C] ;
								save_del << "//n: " << input[i][OFF_C] << endl;
							}
							
						}
						save_del.close();
					}
					break;
				case 3: char temp;
					cout << "\n\nAll admins are going to be deleted. Are you sure?(y|n) ";
					cin >> temp;
				

					if(temp=='y')
					{
						ofstream del_all;
						del_all.open(params);
						del_all.close();
					}
					break;
				case 4: exit=true;
					break;
				default: cout << "\n\nTry again;)\n\n";
					 break;
			}

		out.close();

		}
	}
}


void mani_wordfilter()
{
	bool exit=false;

	char params[100];

	cout << "\n\nFrom which server do you want to manage the admins?\n";

	if(!is_installed())
	return;

	unsigned short int choice;
	cout << "\n : ";
	cin >> choice;


	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcpy(params, param);
	//-------end---------



	if(installed==true)
	{


	strcat(params, "/cfg/mani_admin_plugin/wordfilter.txt");

	char filter[200][50];



	while(!exit)
	{

		int counter = 0;


		ifstream in;
		in.open(params);
		
		cout << "\nhere is your wordfilter:  \n";

		if(in.is_open())
		{
			while (!in.eof())
			{
				char temp[50];

				in.getline(temp, 50);

				switch(temp[0])
				{
					case '/': //nothing to do
					  break;
					case 10: //nothing to do (10 means new line)
						 break;
					case 0: //nothing to do (0 means end of string)
						 break;
					default: strcpy(filter[counter], temp);
						 cout << (counter + 1) << "\t" << filter[counter] << endl;
						counter++; 
						break;
				}
			}
		}
		else
		cout << "\nNo wordfilters. Please add one!\n";

		cout << "\n\n1. Add word\n";
		cout << "2. Delete word\n";
		cout << "3. Delte complete wordfilter\n";
		cout << "4. Exit\n";
		cout << " : ";
		cin >> choice;
		cin.ignore();

		switch (choice)
		{
			case 1: cout << "\nWord: ";
				{
					char temp[50];
					cin.getline(temp, 50);
						ofstream out;
					out.open(params, ios_base::app);
					out << endl << temp;
					out.close();
				}
				break;


				case 2: cout << "\n\nWhich word do you want do delete? ";
					cin >> choice;
		
					choice--;

					if(choice >= counter)
					{
						cout << "\nThis entry does not exist!\n\n";
					}
					else
					{

						ofstream save_del;
						save_del.open(params);




						for (int i = 0;i<counter;i++)
						{

						
							if(i==choice)
							{
								//nothing to do
							}
							else
							{
								save_del << endl << filter[i];
							}
							
						}
						save_del.close();
					}
					break;
				case 3: char temp;
					cout << "\n\nThe hole wordfilter is going to be deleted. Are you sure?(y|n) ";
					cin >> temp;
					

					if(temp=='y')
					{
						ofstream del_all;
						del_all.open(params);
						del_all.close();
					}
					break;
				case 4: exit=true;
					break;
				default: cout << "\n\nTry again;)\n\n";
					 break;
			}
		}
		
	}

}

void mani_rcon()
{


	char params[200];
	bool exit = false;

	cout << "From which server do you wish to edit the rconlist?\n";

	if(!is_installed())
		return;

	unsigned short int choice;
	cout << "\n : ";
	cin >> choice;

	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcpy(params, param);
	//-------end---------

	char buf[50][2][100]; //OFF_name means 0, OFF_C means 1	


	

	if(installed==true)
	{

	
		strcat(params, "/cfg/mani_admin_plugin/rconlist.txt");
		


		


		while (!exit)
		{

			unsigned short int counter = 0;

			ifstream in;
			in.open(params);

			if(in.is_open())
			{
			

				cout << "\n\nCurrent rconlist: \n";


				while(!in.eof())
				{
					char temp[100];
					in.getline(temp, 100);
				
					switch(temp[0])
					{
						case '"': int i;
						  	for(i=1; i<100; i++)
						  	{
								if(temp[i]=='"')
							  	  break;

								buf[counter][OFF_N][(i-1)] = temp[i];
							  }

							buf[counter][OFF_N][(i-1)] = 0; //0 means end of string

							  cout << (counter+1) << ".\t" << buf[counter][OFF_N] << endl;



							  i+=2; //to junp over the '"' and over the ' '

							  int j;
						  	  for(j=0; i<100; i++, j++)
							  {
								if((temp[i]=='/' && temp[(i+1)] == '/') || temp[i] == 0) //0 means end of string
								   break;

								buf[counter][OFF_C][j] = temp[i];
							  }

							  
							  buf[counter][OFF_C][j] = 0; //0 means end of string

							  counter++;
							  
							  temp[0] = 0; //0 means end of string, to avoid the bug with the letter when temp[] = "\"\" "
							  
							  break;
						
						case 10: //10 means new line
							//nothing to do
							break;
						case 0://0 means end of string
							//nothing to do
							break;
						case '/': if (temp [1] == '/')
								break;

						default: strcpy(buf[counter][OFF_N], temp);
							 strcpy(buf[counter][OFF_C], temp);
							 
							 cout << (counter+1) << ".\t" << buf[counter][OFF_N] << endl;
							 
							 counter++;
							
					}

					if(counter > 49)
					{
						never_happen();
						cout << "\nToo many commands(>50)\n";
						break;
					}
				
				}

				in.close();

			}
		
			else
			cout << "\nYou have no rcon commands, please add one!\n";

		
		

			cout << "\n\n1. Add command\n";
			cout << "2. Delete command\n";
			cout << "3. Edit a command\n";
			cout << "4. Add Surf Mod Option\n";
			cout << "5. Delete hole list\n";
			cout << "6. Exit\n";


			cout << " : ";
			cin >> choice;
			cin.ignore();


			switch(choice)
			{
				case 1: cout << "\nCommand: ";
					{
						char command[50];
						cin.getline(command, 50);

						cout << "\nName: ";
						char name[50];
						cin.getline(name, 50);

						ofstream out;
						out.open(params, ios_base::app);
						out << endl << "\"" << name << "\"" << " " << command;
						out.close();
					}
					break;

			
				case 2: cout << "\n\nWhich entry do you want do delete? ";
					cin >> choice;
		
					choice--;

					if(choice >= counter)
					{
						cout << "\nThis entry does not exist!\n\n";
					}
					else
					{

						ofstream save_del;
						save_del.open(params);




						for (int i = 0;i<counter;i++)
						{

						
							if(i==choice)
							{
								//nothing to do
							}
							else
							{
									save_del << endl << "\"" << buf[i][OFF_N] << "\"" << " " << buf[i][OFF_C];
							}
							
						}
						save_del.close();
					}
					break;


				case 3:	cout << "\nWhich entry do you wish do edit? ";
					cin >> choice;
					
					choice--; //for thr right array


					if (choice >= counter)
					{
						cout << "\n\nThis entry does not exist!\n\n";
					}
					else
					{
						cout << "\n\n1. Edit the Name\n";
						cout << "2. Edit the command\n";
						cout << " : ";
						unsigned short int temp_e;
						cin >> temp_e;
						cin.ignore();

						if(temp_e > 2)
						{
							cout << "\n\nWrong choice!\n";
						}
						else
						{
							temp_e--;  //for the right array
							cout << "\nNew name/command: ";
							cin.getline(buf[choice][temp_e], 100);

	

							ofstream save_edit;
							save_edit.open(params);




							for (int i = 0;i<counter;i++)
							    save_edit  << "\"" << buf[i][OFF_N] << "\"" << " " << buf[i][OFF_C] << endl;

				
						
						}

					}

					break;

				case 4: {
						ofstream surf;
						surf.open(params, ios_base::app);

						surf << "\n\"Surf Mod On\" sv_airaccelerate 2000\n";
						surf << "\"Surf Mod Off\" sv_airaccelerate 1";
						surf.close();


					}
					cout << "\nSucces!\n";
					break;

				case 5: char temp;
					cout << "\n\nThe hole rconlist is going to be deleted. Are you sure?(y|n) ";
					cin >> temp;
					

					if(temp=='y')
					{
						ofstream del_all;
						del_all.open(params);
						del_all.close();
					}
					break;
				case 6: exit = true;
					break;
				default: cout << "\n\nTry again;)\n";
			}
		}
	}
}

		
void mani_votequestionlist()
{
	char params[200];
	bool exit = false;

	cout << "From which server do you wish to edit the votequestionlist?\n";

		if(!is_installed())
		return;

	unsigned short int choice;
	cout << "\n : ";
	cin >> choice;

	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcpy(params, param);
	//-------end---------

	char buf[50][2][50]; //OFF_name means 0, OFF_C means 1	


	

	if(installed==true)
	{

	
		strcat(params, "/cfg/mani_admin_plugin/votequestionlist.txt");
		


		


		while (!exit)
		{

			unsigned short int counter = 0;

			ifstream in;
			in.open(params);

			if(in.is_open())
			{
				cout << "\n\nCurrent votequestionlist: \n";


				while(!in.eof())
				{
					char temp[100];
					in.getline(temp, 100);
				
					switch(temp[0])
					{
						case '"': int i;
						  	for(i=1; i<100; i++)
						  	{
								if(temp[i]=='"')
							  	  break;

								buf[counter][OFF_N][(i-1)] = temp[i];
							  }
							  
							  buf[counter][OFF_N][i] = 0; //0 means end of string

							  cout << (counter+1) << ".\t" << buf[counter][OFF_N] << endl;

							 

							  i+=3; //to junp over the '"' and over the ' ' and the second '"'

							  int j;
						  	  for(j=0; i<100; i++, j++)
							  {
								if(temp[i]=='"')
								   break;

								buf[counter][OFF_C][j] = temp[i];
							  }

							  
							  buf[counter][OFF_C][j] = 0; //0 means end of string

							 // cout << buf[0][OFF_C] << " "  << buf[1][OFF_C];

							  counter++;
							  
							  temp[0] = 0; //0means end of string, to avoid the bug with the letter when temp[] = "\"\" "
							  
							  break;
			

							
					}
				
				}

				in.close();
			}
		
			else
			cout << "\nYou have no votequestions, please add one!\n";






			cout << "\n\n1. Add question\n";
			cout << "2. Delete a question\n";
			cout << "3. Edit a question\n";
			cout << "4. Delete hole list\n";
			cout << "5. Exit\n";


			cout << " : ";
			cin >> choice;
			cin.ignore();


			switch(choice)
			{
				case 1: cout << "\nQuestion: ";
					{
						char question[50];
						cin.getline(question, 50);

						cout << "\nName: ";
						char name[50];
						cin.getline(name, 50);

						ofstream out;
						out.open(params, ios_base::app);
						out << endl << "\"" << name << "\"" << " \"" << question << "\"";
						out.close();
					}
					break;

			
				case 2: cout << "\n\nWhich entry do you want do delete? ";
					cin >> choice;
		
					choice--;

					if(choice >= counter)
					{
						cout << "\nThis entry does not exist!\n\n";
					}
					else
					{

						ofstream save_del;
						save_del.open(params);




						for (int i = 0;i<counter;i++)
						{

						
							if(i==choice)
							{
								//nothing to do
							}
							else
							{
								save_del << endl << "\"" << buf[i][OFF_N] << "\"" << " \"" << buf[i][OFF_C] << "\"";
							}
							
						}
						save_del.close();
					}
					break;


				case 3:	cout << "\nWhich entry do you wish do edit? ";
					cin >> choice;
					
					choice--; //for the right array


					if (choice < counter)
					{
						cout << "\n\nThis entry does not exist!\n\n";
					}
					else
					{
						cout << "\n\n1. Edit the Name\n";
						cout << "\n\n2. Edit the question\n";
						cout << " : ";
						unsigned short int temp_e;
						cin >> temp_e;

						if(temp_e > 2)
						{
							cout << "\n\nWrong choice!\n";
						}
						else
						{
							temp_e--;  //for the right array
							cout << "\nNew name/question: ";
							cin.getline(buf[choice][temp_e], 100);

	

							ofstream save_edit;
							save_edit.open(params);




							for (int i = 0;i<counter;i++)
							    save_edit  << "\"" << buf[i][OFF_N] << "\"" << " \"" << buf[i][OFF_C] << "\"" << endl;

				
						
						}

					}

					break;

				case 4: char temp;
					cout << "\n\nThe hole votequestionlist is going to be deleted. Are you sure?(y|n) ";
					cin >> temp;
					

					if(temp=='y')
					{
						ofstream del_all;
						del_all.open(params);
						del_all.close();
					}
					break;
				case 5: exit = true;
					break;
				default: cout << "\n\nTry again;)\n";
					break;
		
		} //switch

	}//while(!exit)




	}//if(installed=true)
}




void mani_ping_reserve(int x)
{
	bool exit = false;


	//x = 1 means reserveslots, x = 2 means pingimmunity

	char params[100];

	cout << "\n\nFrom which server do you want to manage the ";
	
	if(x==1)
	cout << "reserveslots?\n";
	else
	cout << "pingimmunity\n";
	
	
		if(!is_installed())
		return;

	unsigned short int choice;
	cout << "\n : ";
	cin >> choice;


	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcpy(params, param);
	//-------end---------


	if(installed==true)
	{

		if(x==1)
		strcat(params, "/cfg/mani_admin_plugin/reserveslots.txt");
		else
		strcat(params, "/cfg/mani_admin_plugin/pingimmunity.txt");

		cout << endl << endl;

		while (!exit)
		{


			char input[50][2][200]; //OFF_N = 0 means name; OFF_C = 1 means steam id or ip
			
			ifstream in;
			in.open(params);


			int counter = 0;

			if(in.is_open())
			{

				cout << "\n\nCurrent ";
				
				if(x==1)
				cout << "reserveslots: \n";
				else
				cout << "pingimmunities: \n";
				
				while(!in.eof())
				{
					char temp[200];

					in.getline(temp, 200);


				
					switch(temp[0])
					{
						case 'S': if(!strncmp(temp, "STEAM", 5))
							  {
								strcpy(input[counter][OFF_C], temp);
							  }
							  else
							   cout << "\n\nCannot understand: " << temp << "\nIgnoring...\n";

							  break;
						
						case '/': if(!strncmp(temp, "//n: ", 5))
							  {
								strcpy(input[counter][OFF_N], &temp[5]);
								cout << (counter+1) << ".\t" << input[counter][OFF_N] << endl;
								counter++;
							  }
							  break;
						default: 
							if(temp[0] == 10 || temp[0]== 0 || temp[0] == 13) //10 means new line 0 means end of string 13 means "\r"
							 {
								//nothing to do
							 }
						 	 else
						 	 cout << "\n\nCannot understand: " << temp << "\nIgnoring...\n";

							 break;
					}
	
					if(counter > 50)
					{
						never_happen();
						cout << "\nToo many entrys (>50)\n";
						break;
					}
				}
			}
			else
			{
				cout << "\nNo entrys. Please add one\n";
			
			}
			in.close();


			cout << "\n\n1. Add a person\n";
			cout << "2. Delete a person\n";
			cout << "3. Delte all persons\n";
			cout << "4. Exit\n";
			cout << " : ";

			cin >> choice;
			cin.ignore();


			char temp[200];

			ofstream out;
			out.open(params, ios_base::app);

			switch(choice)
			{
				case 1: 
					
					cout << "\n\nSteam ID of the player? ";
					cin.getline(temp, 200);
					
					
					out << endl << temp << endl;


					cout << "\nName or steam account of the player? ";
					cin.getline(temp, 200);
					out << "//n: " << temp;
					break;
				case 2: cout << "\n\nWhich person do you want do delete? ";
					cin >> choice;
		
					choice--;

					if(choice >= counter)
					{
						cout << "\nThis entry does not exist!\n\n";
					}
					else
					{

						ofstream save_del;
						save_del.open(params);




						for (int i = 0;i<counter;i++)
						{

						
							if(i==choice)
							{
								//nothing to do
							}
							else
							{
								save_del << endl << input[i][OFF_C] ;
								save_del << "//n: " << input[i][OFF_C] << endl;
							}
							
						}
						save_del.close();
					}
					break;
				case 3: char temp;
					cout << "\n\nAll persons are going to be deleted. Are you sure?(y|n) ";
					cin >> temp;
				

					if(temp=='y')
					{
						ofstream del_all;
						del_all.open(params);
						del_all.close();
					}
					break;
				case 4: exit=true;
					break;
				default: cout << "\n\nTry again;)\n\n";
					 break;
			}

		out.close();

		}
	}
}

void mani_resw()
{
	cout << "\n\nThis option is only supported by the Counter Strike Source Server\n";

	

	bool exit = false;

	while(!exit)
	{


		ifstream in;
		in.open("server_css/cstrike/cfg/mani_admin_plugin/default_weapon_restrict.txt");


		int counter = 0;
		char resw[50][15];

		cout << "\nCurrent restricted weapons: \n\n";

		if (in.is_open())
		{
			while(!in.eof())
			{
				char temp[100];
				in.getline(temp, 100);
				
				if(temp[0] == '/' && temp[1] == '/')
				continue;

				if(temp[0] == 10 || temp[0]== 0 || temp[0] == 13) //10 means new line 0 means end of string 13 means "\r"
				continue;

				

				if(!strncmp(temp, "awp", 3))
				cout << (counter+1) << ".\tMagnum Sniper Rifle(awp)\n";

				if(!strncmp(temp, "g3sg1", 5))
				cout << (counter+1) << ".\tD3/AU1\n";

				if(!strncmp(temp, "sg550", 5))
				cout << (counter+1) << ".\tKrieg 550 Commando\n";

				if(!strncmp(temp, "galil", 5))
				cout << (counter+1) << ".\tIDF Defender(galil)\n";

				if(!strncmp(temp, "ak47", 4))
				cout << (counter+1) << ".\tCV-47(AK-47)\n";
				
				if(!strncmp(temp, "scout", 5))
				cout << (counter+1) << ".\tSchmidt Scout\n";

				if(!strncmp(temp, "sg552", 5))
				cout << (counter+1) << ".\tKrieg 552\n";

				if(!strncmp(temp, "famas", 5))
				cout << (counter+1) << ".\tClarion 5.56(famas)\n";

				if(!strncmp(temp, "m4a1", 4))
				cout << (counter+1) << ".\tMaverick M4A1 Carbine(m4a1)\n";	

				if(!strncmp(temp, "aug", 3))
				cout << (counter+1) << ".\tBullpup\n";

				if(!strncmp(temp, "glock", 5))
				cout << (counter+1) << ".\t9x19mm Sidearm(glock)\n";

				if(!strncmp(temp, "usp", 3))
				cout << (counter+1) << ".\tKM .45 Tactical(usp)\n";

				if(!strncmp(temp, "p228", 4))
				cout << (counter+1) << ".\t228 Compact\n";

				if(!strncmp(temp, "deagle", 6))
				cout << (counter+1) << ".\tNight Hawk .50C(deagle)\n";

				if(!strncmp(temp, "elite", 5))
				cout << (counter+1) << ".\t.40 Dual Elites\n";

				if(!strncmp(temp, "fiveseven", 9))
				cout << (counter+1) << ".\tES Five//Seven\n";

				if(!strncmp(temp, "m3", 2))
				cout << (counter+1) << ".\tLeone 12 Gauge Super(m3)\n";

				if(!strncmp(temp, "xm1014", 6))
				cout << (counter+1) << ".\tLeone YG1265 Auto Shotgun\n";

				if(!strncmp(temp, "mac10", 5))
				cout << (counter+1) << ".\tIngram MAC-10\n";

				if(!strncmp(temp, "tmp", 3))
				cout << (counter+1) << ".\tSchmidt Machine Pistol(tmp)\n";

				if(!strncmp(temp, "mp5navy", 7))
				cout << (counter+1) << ".\tKM Sub-Machine Gun(mp5)\n";

				if(!strncmp(temp, "ump45", 5))
				cout << (counter+1) << ".\tKM UMP45\n";

				if(!strncmp(temp, "p90", 3))
				cout << (counter+1) << ".\tES C90\n";

				if(!strncmp(temp, "m249", 4))
				cout << (counter+1) << ".\tM249\n";

				if(!strncmp(temp, "flashbang", 9))
				cout << (counter+1) << ".\tFlashbang\n";

				if(!strncmp(temp, "hegrenade", 9))
				cout << (counter+1) << ".\tHE Grenade\n";

				if(!strncmp(temp, "smokegrenade", 12))
				cout << (counter+1) << ".\tSmoke Grenade\n";

				strncpy(resw[counter], temp, 15);

				counter++;
			}
		}
		else
		cout << "No restricted weapons found. Please add one";


		cout << "\n\n1. Add a weapon\n";
		cout << "2. Delete a waepon\n";
		cout << "3. Delete all\n";
		cout << "4. Exit\n";
		cout << " : ";
		unsigned short int choice;

		cin >> choice;

		switch(choice)
		{
			case 1: 


				


				cout << "\n\nWhich weapon should be restricted?\n\n";

				cout << "1.  Magnum Sniper Rifle(awp)\n";
				cout << "2.  D3/AU1\n";
				cout << "3.  Krieg 550 Commando\n";
				cout << "4.  IDF Defender\n";
				cout << "5.  CV-47(AK -47)\n";
				cout << "6.  Schmidt Scout\n";
				cout << "7.  Krieg 552\n";
				cout << "8.  Clarion 5.56(famas)\n";
				cout << "9.  Maverick M4A1 Carbine(m4a1)\n";
				cout << "10. Bullpup\n";
				cout << "11. 9x19mm Sidearm(glock)\n";
				cout << "12. KM .45 Tactical(usp)\n";
				cout << "13. 228 Compact\n";
				cout << "14. Night Hawk .50C(deagle)\n";
				cout << "15. .40 Dual Elites\n";
				cout << "16. ES Five//Seven\n";
				cout << "17. Leone 12 Gauge Super(m3)\n";
				cout << "18. Leone YG1265 Auto Shotgun\n";
				cout << "19. Ingram MAC-10\n";
				cout << "20. Schmidt Machine Pistol(tmp)\n";
				cout << "21. KM Sub-Machine Gun(mp5)\n";
				cout << "22. KM UMP45\n";
				cout << "23. ES C90\n";
				cout << "24. M249\n";
				cout << "25. Flashbang\n";
				cout << "26. HE Grenade\n";
				cout << "27. Smoke Grenade\n";

				cout << " : ";
				cin >> choice;

				

				{
					ofstream add;
					add.open("server_css/cstrike/cfg/mani_admin_plugin/default_weapon_restrict.txt", ios_base::app);
				
					switch(choice)
					{
						case 1: add << endl << "awp";
							break;
						case 2: add << endl << "g3sg1";
							break;
						case 3: add << endl << "sg550";
							break;
						case 4: add << endl << "galil";
							break;
						case 5: add << endl << "ak47";
							break;
						case 6: add << endl << "scout";
							break;
						case 7: add << endl << "sg552";
							break;
						case 8: add << endl << "famas";
							break;
						case 9: add << endl << "m4a1";
							break;
						case 10: add << endl << "aug";
							break;
						case 11: add << endl << "glock";
							break;
						case 12: add << endl << "usp";
							break;
						case 13: add << endl << "p228";
							break;
						case 14: add << endl << "deagle";
							break;
						case 15: add << endl << "elite";
							break;
						case 16: add << endl << "fiveseven";
							break;
						case 17: add << endl << "m3";
							break;
						case 18: add << endl << "xm1014";
							break;
						case 19: add << endl << "mac10";
							break;
						case 20: add << endl << "tmp";
							break;
						case 21: add << endl << "mp5navy";
							break;
						case 22: add << endl << "ump45";
							break;
						case 23: add << endl << "p90";
							break;
						case 24: add << endl << "m249";
							break;
						case 25: add << endl << "flashbang";
							break;
						case 26: add << endl << "hegrenade";
							break;
						case 27: add << endl << "smokegrenade";
							break;
						default: cout << "\nWrong choice!\n\n";
					}

					add.close();

				}

				break;
			case 2: cout << "\n\nWhich entry do you wish to delete? ";
				cin >> choice;

				choice--;

				if(choice >= counter)
				cout << "\n\nEntry does not exist!\n";

				else
				{
					ofstream out;
					out.open("server_css/cstrike/cfg/mani_admin_plugin/default_weapon_restrict.txt");

					for(int i = 0; i<counter; i++)
					{
						if(i==choice);	//nothing to do
						
						else
						{
							out << resw[i] << endl;
						}
						
					}
					out.close();
				}
				break;
			case 3: char temp;
				cout << "\n\nThe hole voterconlist is going to be deleted. Are you sure?(y|n) ";
				cin >> temp;
				

				if(temp=='y')
				{
					ofstream del_all;
					del_all.open("server_css/cstrike/cfg/mani_admin_plugin/default_weapon_restrict.txt");
					del_all.close();
				}
				break;
			case 4: exit =true;
				break;
			default: cout << "\n\nTry again ;)\n";
		}



	}
}


void mani_voterconlist()
{
	
	char params[200];
	bool exit = false;

	cout << "From which server do you wish to edit the rconlist?\n";

		if(!is_installed())
		return;

	unsigned short int choice;
	cout << "\n : ";
	cin >> choice;

	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcpy(params, param);
	//-------end---------

	char buf[50][3][50]; //OFF_name means 0, OFF_C menas 1, 2 is the question





	if(installed==true)
	{

	
		strcat(params, "/cfg/mani_admin_plugin/voterconlist.txt");
		


		


		while (!exit)
		{

			unsigned short int counter = 0;

			ifstream in;
			in.open(params);

			if(in.is_open())
			{
			

				cout << "\n\nCurrent voterconlist: \n";


				while(!in.eof())
				{
					char temp[150];
					in.getline(temp, 150);
				
					switch(temp[0])
					{
						case '"': int i;
						  	for(i=1; i<150; i++)
						  	{
								if(temp[i]=='"')
							  	  break;

								buf[counter][OFF_N][(i-1)] = temp[i];
							  }
							  
							  buf[counter][OFF_N][i] = 0; //0 means end of string
							  
							  cout << (counter+1) << ".\t" << buf[counter][OFF_N] << endl;

							  

							  i+=3; //to junp over the '"' and over the ' ' and the second '"'

							  int q;
						  	  for(q=0; i<150; i++, q++)
							  {
								if(temp[i]=='"')
								   break;

								buf[counter][2][q] = temp[i];
							  }

							  i+=2; //to junp over the '"' and over the ' '

							  int j;
						  	  for(j=0; i<150; i++, j++)
							  {
								if((temp[i]=='/' && temp[(i+1)] == '/') || temp[i]==0) //0 means end of string
								   break;

								buf[counter][OFF_C][j] = temp[i];
							  }

							 
							  buf[counter][OFF_C][j] = 0; //0 means end of string
							  buf[counter][2][q] = 0; //0 means end of string

							  //2 is space for the question

							  counter++;
							  
							  temp[0] = 0; //0means end of string, to avoid the bug with the letter when temp[] = "\"\" "
							  
							  break;
			

							
					}
				
				}

				in.close();

			}
		
			else
			cout << "\nYou have no rcon questions, please add one!\n";

		
		

			cout << "\n\n1. Add command\n";
			cout << "2. Delete command\n";
			cout << "3. Edit a command\n";
			cout << "4. Delete hole list\n";
			cout << "5. Exit\n";


			cout << " : ";
			cin >> choice;
			cin.ignore();


			switch(choice)
			{
				case 1: cout << "\nCommand: ";
					{
						char command[50];
						cin.getline(command, 50);

						cout << "\nName: ";
						char name[50];
						cin.getline(name, 50);

						cout << "\nQuestion: ";
						char question[100];
						cin.getline(question, 100);

						ofstream out;
						out.open(params, ios_base::app);
						out << endl << "\"" << name << "\"" << " \"" << question << "\" " << command;
						out.close();
					}
					break;

			
				case 2: cout << "\n\nWhich entry do you want do delete? ";
					cin >> choice;
		
					choice--;

					if(choice >= counter)
					{
						cout << "\nThis entry does not exist!\n\n";
					}
					else
					{

						ofstream save_del;
						save_del.open(params);




						for (int i = 0;i<counter;i++)
						{

						
							if(i==choice)
							{
								//nothing to do
							}
							else
							{
								save_del << endl << "\"" << buf[i][OFF_N] << "\"" << " \"" << buf[i][2] << "\" " << buf[i][OFF_C];

								//2 is space for the question
							}
							
						}
						save_del.close();
					}
					break;


				case 3:	cout << "\nWhich entry do you wish do edit? ";
					cin >> choice;
					
					choice--; //for the right arry


					if (choice >= counter)
					{
						cout << "\n\nThis entry does not exist!\n\n";
					}
					else
					{
						cout << "\n\n1. Edit the Name\n";
						cout << "2. Edit the command\n";
						cout << "3. Edit the question\n";
						cout << " : ";
						unsigned short int temp_e;
						cin >> temp_e;

						

						if(temp_e > 3)
						{
							cout << "\n\nWrong choice!\n";
						}
						else
						{

							temp_e--;  //for the right array
							cout << "\nNew name/command/question: ";
							cin.getline(buf[choice][temp_e], 100);

	

							ofstream save_edit;
							save_edit.open(params);




							for (int i = 0;i<counter;i++)
							    save_edit << "\"" << buf[i][OFF_N] << "\"" << " \"" << buf[i][2] << "\" " << buf[i][OFF_C] << endl;

				
						
						}

					}

					break;

				case 4: char temp;
					cout << "\n\nThe hole voterconlist is going to be deleted. Are you sure?(y|n) ";
					cin >> temp;
					

					if(temp=='y')
					{
						ofstream del_all;
						del_all.open(params);
						del_all.close();
					}
					break;
				case 5: exit = true;
					break;
				default: cout << "\n\nTry again;)\n";
			}
		}
	}
}

void edit_manicfg(int i)//i == 1 -> mani_Server.cfg; i == 2 -> mani_quake_sounds.cfg
{
	cout << "\n\nFrom which server do you wish to edit the ";
			
	if(i==1)
		cout << "mani_server.cfg?\n";
	else
		cout << "mani_quake_sounds.cfg?\n";
		

	if(!is_installed())
	return;

	unsigned short int choice;
	cout << "\n : ";
	cin >> choice;
	
	char params[100];

	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcpy(params, param);
	//-------end---------
	
	if(i == 1)
	strcat(params, "/cfg/mani_server.cfg");
	else
	strcat(params, "/cfg/mani_quake_sounds.cfg");
	
	
	
	cout << "\n\nWhich editor do you wish to edit the mani_server.cfg\n";
	cout << "1. Nano\n";
	cout << "2. Vim\n";
	cout << "3. Specify Editor\n";
	cout << " : ";
	
	cin >> choice;
	cin.ignore();
	
	switch (choice)
	{
		case 1: strcpy(param, "nano ");
			strcat(param, params);
			system(param);
			//using param because it is more efficent
			break;
		case 2: strcpy(param, "vim ");
			strcat(param, params);
			system(param);
			//using param because it is more efficent
			break;
		case 3: cout << "Command for the editor you want to use?(eg. nano, vim, kate, kwrite, gedit) ";
			char temp[20];
			cin.getline(temp, 20);
			strcpy(param, temp);
			strcat(param, " ");
			strcat(param, params);
			system(param);
			//using param because it is more efficent
			break;
		default: cout << "\n\nWrong choice!\n\n";
			break;
	}
}

void mani_sounds(int i)
{
	
	//1 means quakesoundlist.txt
	//2 means actionsoundlist.txt
	//3 means soundlist.txt



	char params[200];
	bool exit = false;

	
	cout << "From which server do you wish to edit the ";
			
	
	if(i == 1)
	 cout << "quakesoundlist?\n";
	if(i == 2)
		cout << "actionsoundlist?\n";
	if(i == 3)
		cout << "soundlist?\n";

	if(!is_installed())
		return;

	unsigned short int choice;
	cout << "\n : ";
	cin >> choice;

	//if it is really installed	
	installed = false;
	mani_test(choice);
	strcpy(params, param);
	//-------end---------

	char buf[50][2][100]; //OFF_name means 0, OFF_C means 1	


	

	if(installed==true)
	{

		if(i == 1)
		strcat(params, "/cfg/mani_admin_plugin/quakesoundlist.txt");
		
		if(i == 2)
		strcat(params, "/cfg/mani_admin_plugin/actionsoundlist.txt");
		
		if(i == 3)
		strcat(params, "/cfg/mani_admin_plugin/soundlist.txt");
		


		


		while (!exit)
		{

			unsigned short int counter = 0;

			ifstream in;
			in.open(params);

			if(in.is_open())
			{
			

				cout << "\n\nCurrent list: \n";


				while(!in.eof())
				{
					char temp[100];
					in.getline(temp, 100);
				
					switch(temp[0])
					{
					case '"': int i;
						for(i=1; i<100; i++)
						{
							if(temp[i]=='"')
								break;

							buf[counter][OFF_N][(i-1)] = temp[i];
						}

						buf[counter][OFF_N][(i-1)] = 0; //0 means end of string

						cout << (counter+1) << ".\t" << buf[counter][OFF_N] << endl;



						i++; //to junp over the '"' and over the ' '

						int j;
						for(j=0; i<100; i++, j++)
						{
							if((temp[i]=='/' && temp[(i+1)] == '/') || temp[i] == 0) //0 means end of string
								break;

							buf[counter][OFF_C][j] = temp[i];
						}

							  
						buf[counter][OFF_C][j] = 0; //0 means end of string

						counter++;
							  
						temp[0] = 0; //0 means end of string, to avoid the bug with the letter when temp[] = "\"\" "
							  
						break;
						
					case 10: //10 means new line
						//nothing to do
						break;
					case 13://13 means return ( '/r' )
						//nothing to do
						break;
					case '/': if (temp [1] == '/');
						  else
							cout << "\n\nCannot understand " << temp << "\nIgnoring...\n";
						break;
						case 0: break; //nothing to do, 0 means end of string

					default:cout << "\n\nCannot understand " << temp << "\nIgnoring...\n";
						break;
							
					}

					if(counter > 49)
					{
						never_happen();
						cout << "\nToo many sounds(>50)\n";
						break;
					}
				
				}

				in.close();

			}
		
			else
				cout << "\nYou have no sounds, please add one!\n";

		
		

			cout << "\n\n1. Add sound\n";
			cout << "2. Delete sound\n";
			cout << "3. Edit a sound\n";
			cout << "4. Delete hole list\n";
			cout << "5. Exit\n";


			cout << " : ";
			cin >> choice;
			cin.ignore();


			switch(choice)
			{
				case 1: cout << "\nPath: ";
				{
					char path[50];
					cin.getline(path, 50);

					cout << "\nName: ";
					char name[50];
					cin.getline(name, 50);

					ofstream out;
					out.open(params, ios_base::app);
					out << endl << "\"" << name << "\"" << " " << path;
					out.close();
				}
				break;

			
				case 2: cout << "\n\nWhich entry do you want do delete? ";
				cin >> choice;
		
				choice--;

				if(choice >= counter)
				{
					cout << "\nThis entry does not exist!\n\n";
				}
				else
				{

					ofstream save_del;
					save_del.open(params);




					for (int i = 0;i<counter;i++)
					{

						
						if(i==choice)
						{
								//nothing to do
						}
						else
						{
							save_del << endl << "\"" << buf[i][OFF_N] << "\"" << " " << buf[i][OFF_C];
						}
							
					}
					save_del.close();
				}
				break;


				case 3:	cout << "\nWhich entry do you wish do edit? ";
				cin >> choice;
					
				choice--; //for thr right array


				if (choice >= counter)
				{
					cout << "\n\nThis entry does not exist!\n\n";
				}
				else
				{
					cout << "\n\n1. Edit the Name\n";
					cout << "2. Edit the path\n";
					cout << " : ";
					unsigned short int temp_e;
					cin >> temp_e;
					cin.ignore();

					if(temp_e > 2)
					{
						cout << "\n\nWrong choice!\n";
					}
					else
					{
						temp_e--;  //for the right array
						cout << "\nNew name/path: ";
						cin.getline(buf[choice][temp_e], 100);

	

						ofstream save_edit;
						save_edit.open(params);




						for (int i = 0;i<counter;i++)
							save_edit  << "\"" << buf[i][OFF_N] << "\"" << " " << buf[i][OFF_C] << endl;

				
						
					}

				}

				break;

			case 4: char temp;
				cout << "\n\nThe hole list is going to be deleted. Are you sure?(y|n) ";
				cin >> temp;
					

				if(temp=='y')
				{
					ofstream del_all;
					del_all.open(params);
					del_all.close();
				}
				break;
			case 5: exit = true;
				break;
				default: cout << "\n\nTry again;)\n";
			}
		}
	}
}



void config_mani()
{

	bool exit = false;

	while(!exit)
	{
		cout << "\n\n1.  Install mani admin plugin\n";
		cout << "2.  Install quake sound pack\n";
		cout << "3.  Deactivate mani admin plugin\n";
		cout << "4.  Configure Admins\n";
		cout << "5.  Configure votemapslist\n";
		cout << "6.  Configure wordfilter\n";
		cout << "7.  Configure rconlist\n";
		cout << "8.  Configure votequestionlist\n";
		cout << "9.  Configure reserveslots\n";
		cout << "10. Configure pingimmunities\n";
		cout << "11. Configure restricted weapons\n";
		cout << "12. Configure voterconlist\n";
		cout << "13. Edit mani_server.cfg (main config for mani admin plugin)\n";
		cout << "14. Edit mani_quake_sounds.cfg (main config for the quake sounds)\n";
		cout << "15. Configure quake sounds\n";
		cout << "16. Configure actionsoundlist\n";
		cout << "17. Configure soundlist\n";
		cout << "18. Exit\n";
		cout << " : ";

		unsigned short int choice;
		cin >> choice;
		cin.ignore();

		switch (choice)
		{
			case 1: install_mani();
				break;
			case 2: install_quake();
				break;
			case 3:	deactivate_mani();
				break;
			case 4: mani_admins();
				break;
			case 5: edit_mapcl(3); //3 means votemaplist.txt
				break;
			case 6: mani_wordfilter();
				break;
			case 7: mani_rcon();
				break;
			case 8: mani_votequestionlist();
				break;
			case 9: mani_ping_reserve(1); //1 means reserveslots
				break;
			case 10: mani_ping_reserve(2); //2 means pingimmunity
				break;
			case 11: mani_resw();
				 break;
			case 12: mani_voterconlist();
				 break;
			case 13: edit_manicfg(1); //1 means mani_server.cfg
				 break;
			case 14: edit_manicfg(2); //2 means mani_quake_sounds.cfg
				break;
			case 15: mani_sounds(1); //1 means quakesoundlist.txt
				break;
			case 16: mani_sounds(2); //2 means actionsoundlist.txt
				break;
			case 17: mani_sounds(3); //3 means soundlist.txt
				break;
			case 18: exit = true;
				break;
			default: cout << "\n\nTry again;)\n";
		}
	}
}

void config_servercfg()
{
	cout << "\n\nFrom which server do you wish to edit the server.cfg?\n";
	
	if(!is_installed())
		return;
	
	cout << " : ";
	unsigned int choice;
	cin >> choice;
	
	
	
	strcpy(param, ".steamserverutil/"); //using global array here

	installed = false;


	switch(choice)
	{
		case 1:	if(server_css==true)
		{
						
			strcat(param, "servers_source/cstrike/");
			installed = true;
		}
		else
			not_installed();
		break;
		case 2:	if(server_dods==true)
		{
			strcat(param, "servers_source/dod/");
											
				
			installed = true;
		}
		else
			not_installed();
		break;
		case 3:	if(server_garrysmod==true)
		{
			strcat(param, "servers_source/garrysmod/");
									
					
			installed = true;
		}
		else
			not_installed();
		break;
		case 4:	if(server_hl2mp==true)
		{
			strcat(param, "servers_source/hl2mp/");
						
									
			installed = true;
		}
		else
			not_installed();
		break;
		case 5:	if(server_tf==true)
		{	
			strcat(param, "servers_source/tf/");
					
			installed = true;
		}
		else
			not_installed();
		break;
		case 6:	if(server_cs==true)
		{
			strcat(param, "servers_hl1/cstrike/");
									
									
			installed = true;
		}
		else
			not_installed();
		break;
		case 7:	if(server_czero==true)
		{
			strcat(param, "servers_hl1/czero/");
							
									
			installed = true;
		}
		else
			not_installed();
		break;
		case 8:	if(server_dmc==true)
		{
			strcat(param, "servers_hl1/dmc/");
				
						
			installed = true;
		}
		else
			not_installed();
		break;
		case 9:	if(server_dod==true)
		{
			strcat(param, "servers_hl1/dod/");
								
					
			installed = true;
		}
		else
			not_installed();
		break;
		case 10:	if(server_gearbox==true)
		{
			strcat(param, "servers_hl1/gearbox/");
									
			
			installed = true;
		}
		else
			not_installed();
		break;
		case 11:	if(server_ricochet==true)
		{
			strcat(param, "servers_hl1/ricochet/");
									
			
			installed = true;
		}
		else
			not_installed();
		break;
		case 12:	if(server_tfc==true)
		{
			strcat(param, "servers_hl1/tfc/");
									
			
			installed = true;
		}
		else
			not_installed();
		break;
		case 13:	if(server_darkmessiah==true)
		{

			strcat(param, "server_darkmessiah/");
									
			installed = true;
			
		}
		else
			not_installed();
		break;
		case 14:	if(server_chivalry==true)
		{

			strcat(param, "servers_source/ageofchivalry/");
									
			installed = true;
			
		}
		else
			not_installed();
		break;
		case 15:	if(server_diprip==true)
		{

			strcat(param, "servers_source/diprip/");
									
			installed = true;
			
		}
		else
			not_installed();
		break;
		case 16:	if(server_insurgency==true)
		{

			strcat(param, "servers_source/insurgency/");
									
			installed = true;
			
		}
		else
			not_installed();
		case 17:	if(server_synergy==true)
		{
			strcat(param, "servers_source/sunergy/");
									
			installed = true;
			
		}
		else
			not_installed();
		break;
		case 18:	if(server_zps==true)
		{

			strcat(param, "servers_source/zps/");
									
			installed = true;
			
		}
		else
		not_installed();
		break;
		
		default: cout << "\n\nTry again ;)\n\n";
		
		break;
	}
	
	strcat(param, "cfg/server.cfg");
	
	
	
	if(installed)
	{
		bool exit = false;
	
		while(!exit)
		{
	
			ifstream in;
			in.open(param);
	
			char input[200][2][100]; //200 commands and 100 chars length
			int counter = 0;
	
			cout << "\n\nHere is your current server.cfg: \n\n\n";
	
			if(in.is_open())
			{
	
				while(!in.eof())
				{
					char temp[100];
					in.getline(temp, 100);
		
 					switch(temp[0])
					{
						case '/': if(!strncmp(temp, "//n: ", 5))
							{
								strcpy(input[counter][OFF_N], &temp[5]);
								cout << (counter+1) << ".\t" << input[counter][OFF_N] << endl;
								counter++;
							}
							break;
						default: strcpy(input[counter][OFF_C], temp);
							break;
			
					}
		
				}
		
		
			}
			else
			cout << "\n\nNo commands in server.cfg, please add one ;)\n\n";
	
			in.close();
	
			cout << "\n\n1. Add command\n";
			cout << "2. Delete a command\n";
			cout << "3. Delte the hole list\n";
			cout << "4. Exit\n";
			cout << " : ";
	
			cin >> choice;
			cin.ignore();
	
	
	
	
	
	
			switch(choice)
			{
		
				case 1: cout << "\n\nCommand: ";
					{
						char command[100];
						cin.getline(command, 100);
						
						cout << "Name of the command: ";
						char name[100];
						cin.getline(name, 100);
						
						ofstream out;
						out.open(param, ios_base::app);
				
						out << endl << "//n: " << name;
						out << endl << command;
				
						out.close();
					}
			
			
			
			
					break;
				case 2: cout << "\n\nWhich command do you want to delete?\n\n";
						
					cout << " : ";
					cin >> choice;
				
					choice--;


					if(choice > counter)
					{
						cout << "\n\nThis entry does not exist!";
					}
					else
					{

						ofstream save_del;
						save_del.open(param);




						for (int i = 0;i<counter;i++)
						{

								
							if(i==choice)
							{
								//nothing to do
							}
							else
							{
								save_del << "//n: " << input[i][OFF_N] << endl;
								save_del << input[i][OFF_C] << endl;
							}
								
						}
						save_del.close();
					}
					break;

			case 3: char temp;
				cout << "\n\nAll commands in server.cfg are going to be deleted. Are you sure?(y|n) ";
				cin >> temp;
				

				if(temp=='y')
				{
					ofstream del_all;
					del_all.open(param);
					del_all.close();
				}
				break;
			case 4: exit=true;
				break;
			default: cout << "\n\nTry again ;)\n";
		} 
	
		}
	
	}
	
	
}


void show_stats()
{
	cout << "\n\nFrom which server do you wish to see the stats?\n";
	
	if(!is_installed())
		return;
	
	
	
	cout << " : ";
	unsigned int choice;
	cin >> choice;
	
	
	strcpy(param, ".steamserverutil/"); //using global array here

	

	switch(choice)
	{
		case 1:	if(server_css==true)
		{
						
			strcat(param, "servers_source/cstrike/");
			installed = true;
		}
		else
			not_installed();
		break;
		case 2:	if(server_dods==true)
		{
			strcat(param, "servers_source/dod/");
											
				
			installed = true;
		}
		else
			not_installed();
		break;
		case 3:	if(server_garrysmod==true)
		{
			strcat(param, "servers_source/garrysmod/");
									
					
			installed = true;
		}
		else
			not_installed();
		break;
		case 4:	if(server_hl2mp==true)
		{
			strcat(param, "servers_source/hl2mp/");
						
									
			installed = true;
		}
		else
			not_installed();
		break;
		case 5:	if(server_tf==true)
		{	
			strcat(param, "servers_source/tf/");
					
			installed = true;
		}
		else
			not_installed();
		break;
		case 6:	if(server_cs==true)
		{
			strcat(param, "servers_hl1/cstrike/");
									
									
			installed = true;
		}
		else
			not_installed();
		break;
		case 7:	if(server_czero==true)
		{
			strcat(param, "servers_hl1/czero/");
							
									
			installed = true;
		}
		else
			not_installed();
		break;
		case 8:	if(server_dmc==true)
		{
			strcat(param, "servers_hl1/dmc/");
				
						
			installed = true;
		}
		else
			not_installed();
		break;
		case 9:	if(server_dod==true)
		{
			strcat(param, "servers_hl1/dod/");
								
					
			installed = true;
		}
		else
			not_installed();
		break;
		case 10:	if(server_gearbox==true)
		{
			strcat(param, "servers_hl1/gearbox/");
									
			
			installed = true;
		}
		else
			not_installed();
		break;
		case 11:	if(server_ricochet==true)
		{
			strcat(param, "servers_hl1/ricochet/");
									
			
			installed = true;
		}
		else
			not_installed();
		break;
		case 12:	if(server_tfc==true)
		{
			strcat(param, "servers_hl1/tfc/");
									
			
			installed = true;
		}
		else
			not_installed();
		break;
		case 13:	if(server_darkmessiah==true)
		{

			strcat(param, "server_darkmessiah/");
									
			installed = true;
			
		}
		else
			not_installed();
		break;
		case 14:	if(server_chivalry==true)
		{

			strcat(param, "servers_source/ageofchivalry/");
									
			installed = true;
			
		}
		else
			not_installed();
		break;
		case 15:	if(server_diprip==true)
		{

			strcat(param, "servers_source/diprip/");
									
			installed = true;
			
		}
		else
			not_installed();
		break;
		case 16:	if(server_insurgency==true)
		{

			strcat(param, "servers_source/insurgency/");
									
			installed = true;
			
		}
		else
			not_installed();
		case 17:	if(server_synergy==true)
		{
			strcat(param, "servers_source/sunergy/");
									
			installed = true;
			
		}
		else
			not_installed();
		break;
		case 18:	if(server_zps==true)
		{

			strcat(param, "servers_source/zps/");
									
			installed = true;
			
		}
		else
			not_installed();
		break;
		
		default: cout << "\n\nTry again ;)\n\n";
		
		break;
	}
	
	strcat(param, "stats.txt");
	
	
	cout << "\n\nHere are the current stats: \n\n\n";
	
	ifstream in;
	in.open(param);
	
	if(in.is_open())
	{
	
		while(!in.eof())
		{
			char temp[100];
			in.getline(temp, 100);
		
			cout << temp << endl;
		}
		
		
	}
	else
	cout << "\n\nOops there are no stats ;)\n\n";
				
	in.close();
				
	
				
	cout << "\n\nDelete all stats?(y|n) ";
	char asd;
	cin >> asd;
	
	if(asd=='y')
	{
		cout << "Are you sure, really delete all stats?(y|n) ";
		cin >> asd;
		
		if(asd=='y')
		{
			ofstream delete_;
			delete_.open(param);
			delete_.close();
			cout << "\n\nDeleted succesfully!!\n\n";
		}
		
		
	}
}


//here you can configure servers
void config_server()
{
	bool exit=false;

	while(!exit)
	{
		unsigned short int choice;
		cout << "\n\n1. Copy maps into server\n";
		cout << "2. Edit maplist\n";
		cout << "3. Edit mapcylce\n";
		cout << "4. Edit server.cfg\n";
		cout << "5. Show stats\n";
		cout << "6. Configure mani admin plugin\n";
		cout << "7. Exit to main menu\n";
		cout << " : ";
		cin  >> choice;	

		switch(choice)
		{
			case 1: copy_maps();
				break;
			case 2: edit_mapcl(1); //1 means edit maplist.txt
				break;
			case 3: edit_mapcl(2); //2 means edit mapcycle.txt
				break;
			case 4: config_servercfg();
				break;
			case 5: show_stats();
				break;
			case 6:	config_mani();
				break;
			case 7: exit=true;
				break;
			default: cout << "\n\nWrong choice. Try again;)";
				 break;
		}
	}
}


//here you can update the server with verifying all data!
void update_server()
{
	
	cout << "\n\nWhich server do you wish to update?\n\n";
	
		if(!is_installed())
		return;
	
	

	unsigned short int choice;
	cout << " : ";
	cin >> choice;
	cin.ignore();

	switch(choice)
	{
		case 1:	if(server_css==true)
				{
					cout << "\n\nUpdating Counter Strike-Source...";
					system(".steamserverutil/./steam -command update -game \"Counter-Strike Source\" -dir .steamserverutil/servers_source/ -verify_all");
				}
				else
				not_installed();
				break;
		case 2:	if(server_dods==true)
				{
					cout << "\n\nUpdating Day of Defeat Source...";
					system(".steamserverutil/./steam -command update -game \"dods\" -dir .steamserverutil/servers_source/ -verify_all");
				}
				else
				not_installed();
				break;
				
		case 3:	if(server_garrysmod==true)
				{
					cout << "\n\nUpdating Garrysmod...";
					system(".steamserverutil/./steam -command update -game \"garrysmod\" -dir .steamserverutil/servers_source/ -verify_all");
				}
				else
					not_installed();
				break;

		case 4:	if(server_hl2mp==true)
				{
					cout << "\n\nUpdating Half Life 2 Death Match...";
					system(".steamserverutil/./steam -command update -game \"hl2mp\" -dir .steamserverutil/servers_source/ -verify_all");
				}
				else
				not_installed();
				break;
		case 5:	if(server_tf==true)
				{
					cout << "\n\nUpdating Team Fortress...";
					system(".steamserverutil/./steam -command update -game \"tf\" -dir .steamserverutil/servers_source/ -verify_all");
				}
				else
				not_installed();
				break;
		case 6:	if(server_cs==true)
				{
					cout << "\n\nUpdating Counter Strike...";
					system(".steamserverutil/./steam -command update -game \"cs\" -dir .steamserverutil/servers_hl1/ -verify_all");
				}
				else
				not_installed();
				break;
		case 7:	if(server_czero==true)
				{
					cout << "\n\nUpdating Counter Strike Condition Zero...";
					system(".steamserverutil/./steam -command update -game \"czero\" -dir .steamserverutil/servers_hl1/ -verify_all");
				}
				else
				not_installed();
				break;
		case 8:	if(server_dmc==true)
				{
					cout << "\n\nUpdating Death Match Classic...";
					system(".steamserverutil/./steam -command update -game \"dmc\" -dir .steamserverutil/servers_hl1/ -verify_all");
				}
				else
				not_installed();
				break;
		case 9:	if(server_dod==true)
				{
					cout << "\n\nUpdating Day of Defeat...";
					system(".steamserverutil/./steam -command update -game \"dod\" -dir .steamserverutil/servers_hl1/ -verify_all");
				}
				else
				not_installed();
				break;
		case 10:	if(server_gearbox==true)
				{
					cout << "\n\nUpdating Opposing Force...";
					system(".steamserverutil/./steam -command update -game \"gearbox\" -dir .steamserverutil/servers_hl1/ -verify_all");
				}
				else
				not_installed();
				break;
		case 11:	if(server_ricochet==true)
				{
					cout << "\n\nUpdating ricochet...";
					system(".steamserverutil/./steam -command update -game \"ricochet\" -dir .steamserverutil/servers_hl1/ -verify_all");
				}
				else
				not_installed();
				break;
		case 12:	if(server_tfc==true)
				{
					cout << "\n\nUpdating Team Fortress Classic...";
					system(".steamserverutil/./steam -command update -game \"tfc\" -dir .steamserverutil/servers_hl1/ -verify_all");
				}
				else
				not_installed();
				break;
		case 13:	if(server_darkmessiah==true)
				{
					cout << "\n\nUpdating Dark Messiah...";
					system(".steamserverutil/./steam -command update -game \"darkmessiah\" -dir server_darkmessiah -verify_all");
				}
				else
				not_installed();
				break;
		case 14:	if(server_chivalry==true)
				{
					cout << "\n\nUpdating Age of Chivalry Strike-Source...";
					system(".steamserverutil/./steam -command update -game \"ageofchivalry\" -dir .steamserverutil/servers_source/ -verify_all");
				}
				else
					not_installed();
				break;
		case 15:	if(server_diprip==true)
				{
					cout << "\n\nUpdating D.I.P.R.I.P...";
					system(".steamserverutil/./steam -command update -game \"Counter-Strike Source\" -dir .steamserverutil/servers_source/ -verify_all");
				}
				else
					not_installed();
				break;
				
		case 16:	if(server_insurgency==true)
				{
					cout << "\n\nUpdating Insurgency...";
					system(".steamserverutil/./steam -command update -game \"insurgency\" -dir .steamserverutil/servers_source/ -verify_all");
				}
				else
					not_installed();
				break;
		case 17:	if(server_synergy==true)
				{
					cout << "\n\nUpdating Synergy...";
					system(".steamserverutil/./steam -command update -game \"synergy\" -dir .steamserverutil/servers_source/ -verify_all");
				}
				else
					not_installed();
				break;
		case 18:	if(server_zps==true)
				{
					cout << "\n\nUpdating Zombie Panic: Source (HL2 Mod)...";
					system(".steamserverutil/./steam -command update -game \"zps\" -dir .steamserverutil/servers_source/ -verify_all");
				}
				else
					not_installed();
				break;
		default: cout << "\n\nTry again ;)\n\n";
				break;
	}

	


}


//to update the client
void update_client()
{
	cout << "Updating Steam Linux Client\n\n";
	system(".steamserverutil/./steam -command update");

	cout << "\n\nUpdated\n\n";
}

void delete_server()
{
	cout << "\nWhich server do you wish to delete?\n";
	
	//if(!is_installed())
	//	return;
	
	is_installed();

	
	cout << "19. Delete the hole content\n";
	cout << " : ";
	unsigned int choice;
	cin >> choice;
	
	cin.ignore();

	
	bool installed=false; //is set true when server is installed

	
	strcpy(param, "rm -rf .steamserverutil/"); //using global array here

	

	switch(choice)
	{
		case 1:	if(server_css==true)
			{
						
				strcat(param, "servers_source/cstrike/ ");
				installed = true;
			}
			else
			not_installed();
			break;
		case 2:	if(server_dods==true)
			{
				strcat(param, "servers_source/dod ");
											
				
				installed = true;
			}
			else
			not_installed();
			break;
		case 3:	if(server_garrysmod==true)
			{
				strcat(param, "servers_source/garrysmod");
									
					
				installed = true;
			}
			else
			not_installed();
			break;
		case 4:	if(server_hl2mp==true)
			{
				strcat(param, "servers_source/hl2mp");
						
									
				installed = true;
			}
			else
			not_installed();
			break;
		case 5:	if(server_tf==true)
			{	
				strcat(param, "servers_source/tf");
					
				installed = true;
			}
			else
			not_installed();
			break;
		case 6:	if(server_cs==true)
			{
				strcat(param, "servers_hl1/cstrike");
									
									
				installed = true;
			}
			else
			not_installed();
			break;
		case 7:	if(server_czero==true)
			{
				strcat(param, "servers_hl1/czero");
							
									
				installed = true;
			}
			else
			not_installed();
			break;
		case 8:	if(server_dmc==true)
			{
				strcat(param, "servers_hl1/dmc");
				
						
				installed = true;
			}
			else
			not_installed();
			break;
		case 9:	if(server_dod==true)
				{
					strcat(param, "servers_hl1/dod");
								
					
					installed = true;
				}
				else
				not_installed();
				break;
		case 10:	if(server_gearbox==true)
				{
					strcat(param, "servers_hl1/gearbox");
									
			
					installed = true;
				}
				else
				not_installed();
				break;
		case 11:	if(server_ricochet==true)
				{
					strcat(param, "servers_hl1/ricochet/");
									
			
					installed = true;
				}
				else
				not_installed();
				break;
		case 12:	if(server_tfc==true)
				{
					strcat(param, "servers_hl1/tfc/");
									
			
					installed = true;
				}
				else
				not_installed();
				break;
		case 13:	if(server_darkmessiah==true)
				{

					strcat(param, "server_darkmessiah/ ");
									
					installed = true;
			
				}
				else
				not_installed();
				break;
		case 14:	if(server_chivalry==true)
				{

					strcat(param, "servers_source/ageofchivalry/ ");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		case 15:	if(server_diprip==true)
				{

					strcat(param, "servers_source/diprip/ ");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		case 16:	if(server_insurgency==true)
				{

					strcat(param, "servers_source/insurgency/ ");
									
					installed = true;
			
				}
				else
					not_installed();
		case 17:	if(server_synergy==true)
				{
					strcat(param, "servers_source/sunergy/ ");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		case 18:	if(server_zps==true)
				{

					strcat(param, "servers_source/zps/ ");
									
					installed = true;
			
				}
				else
					not_installed();
				break;
		case 19:	cout << "\nAre you sure?(y|n) ";
				char sure;
				cin >> sure;
		
				if(sure == 'y')
				{
					cout << "\n\nDeleting, this can take a few moments...";
					cout << flush;
			
					system("rm -rf .steamserverutil");
				}
				break;
		default: cout << "\n\nTry again ;)\n\n";
		
			break;
	}
	
	
	if(installed)
	{
		cout << "\nAre you sure?(y|n) ";
		char sure;
		
		cin >> sure;
		
		if(sure == 'y')
		{
			cout << "\n\nDeleting, this can take a few moments...";
			cout << flush;
			
			system(param);
			
			cout << "\n\nRemoving server from file installed_servers...";
			cout << flush;
			
			//to to ;)
			
			char array[20];
			char array_2[25][20];
			
			
			switch(choice)
			{
				case 1:	strcpy(array, "css");
						break;
				case 2:	strcpy(array, "dods");
						break;
				case 3:	strcpy(array, "garrysmod");
						break;
				case 4:	strcpy(array, "hl2mp");
						break;
				case 5:	strcpy(array, "tf");
						break;
				case 6:	strcpy(array, "cstrike");
						break;
				case 7:	strcpy(array, "czero");
						break;
				case 8:	strcpy(array, "dmc");
						break;
				case 9:	strcpy(array, "dod");
						break;
				case 10:strcpy(array, "gearbox");
						break;
				case 11:strcpy(array, "ricochet");
						break;
				case 12:strcpy(array, "tfc");
						break;
				case 13:strcpy(array, "darkmessiah");
						break;
				case 14:strcpy(array, "chivalry");
						break;
				case 15:strcpy(array, "diprip");
						break;
				case 16:strcpy(array, "insurgency");
						break;
				case 17:strcpy(array, "synergy");
						break;
				case 18:strcpy(array, "zps");
						break;
			}
		
			ifstream read;
			read.open(".steamserverutil/installed_servers"); //to save the sercers in memory
		
			
			int counter = 0;
			
			while(!read.eof()) //saves in memory
			{
				read.getline(array_2[counter], 20);
				counter ++;
			}
			
			read.close();
		
			ofstream out;
			out.open(".steamserverutil/installed_servers"); //writes complete new file
			
			for(int i = 0; i < counter; i++)
			{
				if(!strcmp(array_2[i], array)); //nothing to do
					
				else
				out << endl << array_2[i];
			}
			
			out.close();
			
			cout << "\nSucces!\n\n";
		
		}
		
	}
	
	
	
	
	
}

void started_serversWithScreen(int i)
{
	if(i==0)
		cout << "\n1.  Counter Strike Source Server is running\n";
	if(i==1)
		cout << "\n2.  Day of Defeat is running\n";
	if(i==2)
		cout << "\n3.  Garrysmod Server is running\n";
	if(i==3)
		cout << "\n4.  Half Life 2 Death Match Server is running\n";
	if(i==4)
		cout << "\n5.  Team Fortress Server is running\n";
	if(i==5)
		cout << "\n6. Opposing Force Server is running\n";
	if(i==6)
		cout << "\n7.  Counter Strike Condition Zero Server is running\n";
	if(i==7)
		cout << "\n8.  Death Match Classic Server is running\n";
	if(i==8)
		cout << "\n9.  Day of Defeat Server is running\n";
	if(i==9)
		cout << "\n10. Counter Strike Source Server is running\n";
	if(i==10)
		cout << "\n11. Ricochet Server is running\n";
	if(i==11)
		cout << "\n12. Team Fortress Classic Server is running\n";
	if(i==12)
		cout << "\n13. Dark Messiah is running\n";
	if(i==13)
		cout << "\n14. Chivalry Server is running\n";
	if(i==14)
		cout << "\n15. D.I.P.R.I.P Server is running\n";
	if(i==15)
		cout << "\n16. Incurgency Server is running\n";
	if(i==16)
		cout << "\n17. Synergy Server is running\n";
	if(i==17)
		cout << "\n18. Zombie Panic Mod Server is running\n";
}

void screen_test()
{
	
	bool exit = false;
	
	while(!exit)
	{
	
		cout << "\n\nCurrently running servers with \"screen\": \n\n";
	
		char command[300];
	
		strcpy(command, "screen -ls | grep ");
	
	
		char array[18][15]; //first saving the process name in screen and the the id
		
		strcpy(array[0], "css");
		strcpy(array[1], "dods");
		strcpy(array[2], "garrysmod");
		strcpy(array[3], "hl2mp");
		strcpy(array[4], "tf");
		strcpy(array[5], "cstrike");	
		strcpy(array[6], "cscz");
		strcpy(array[7], "dmc");
		strcpy(array[8], "dod");
		strcpy(array[9], "gearbox");
		strcpy(array[10], "ricochet");
		strcpy(array[11], "tfc");
		strcpy(array[12], "darkmessiah");
		strcpy(array[13], "chivalry");
		strcpy(array[14], "diprip");
		strcpy(array[15], "insurgency");
		strcpy(array[16], "synergy");
		strcpy(array[17], "zps");
		
		char cur_id[17][32];
	
		for (int i = 0; i < 18; i++)
		{
	
			
	
		
		
			
			strcpy(&command[18], array[i]);
			strcat(command, " > temp.txt");
		
			system(command);
		
			//reading temp.txt
		
			ifstream in;
			in.open("temp.txt");
		
			if(in.is_open())
			{
			
				while (!in.eof())
				{
					char temp[50];
					in.getline(temp, 50);
				
					switch(temp[0])
					{
					
						case 0x09: //means a tab 	 <- like this ;)
							for(int n=0; n<(32-4); n++)
							{
								if(temp[(n+1)] == '.')
								{
									cur_id[i][n] = 0;
									break;
								}
								else
								cur_id[i][n] = temp[(n+1)];
								
							}
							
							started_serversWithScreen(i);
				
						
							break;
					}
				}
				
				in.close();
				system("rm -rf temp.txt");
			}
			else
			{
				in.close();
				cout << "\n\nAn error occured while reading temp.txt, maybe you have no permission to write or screen is not installed!\n";
				never_happen();
			
				return;
			}
			
			
			
		}
		
		
		
		
		cout << "\n\n1. Kill a server\n";
		cout << "2. Exit\n";
		cout << " : ";
		
		unsigned int choice;
		cin >> choice;
		
		switch (choice)
		{
			case 1: cout << "\n\nWhich server should be halted? ";
				cin >> choice;
				if(choice > 18)
					cout << "Wrong choice!";
			
				else
				{
					char temp[10];
					strcpy(temp, "kill ");
					strcat(temp, cur_id[(choice-1)]);
					
					cout << temp;
					
					cout << "\n\nKilling the server...";
					cout << flush;
					system(temp);
				}
				break;
			case 2: exit = true;
				break;
			default: cout << "\n\nTry again;)\n";
				break;
			
		}
		
		
	
	}
	
}


//about box
void about()
{
	cout << endl << endl << endl;
	
	cout << "steamserverutil " << _version << endl;
	cout << "Copyright (C) 2008  MJ, hanfman_cool@web.de\n";
	cout << "steamserverutil comes with ABSOLUTELY NO WARRANTY\n\n";
			
	cout << "For the GPL v2 license look \"http://www.gnu.org/licenses/gpl-2.0.html\"\n";
	cout << "For the source code look \"http://code.google.com/p/steamserverutil/downloads/list\"\n";
	
}

//main menu
int main(int argc, char *argv[]) //the parameters aren't needed yet
{
	system("clear;clear;clear"); //for a better look ;)
	
	char choice;

	cout << "steamserverutil " << _version << ", steamserverutil.googlecode.com\n";
	
	
	
	
	

	ifstream test_file;
	test_file.open(".steamserverutil/hldsupdatetool.bin");

	if(test_file.is_open())
	{
		cout << "found hldsupdatetool.bin\n";
	}
	else
	{
		
		cout << "Creating directory...\ndownloading hldsupdatetool.bin with wget...\n\n";
		system("mkdir .steamserverutil");
		system("cd .steamserverutil && wget http://www.steampowered.com/download/hldsupdatetool.bin && chmod +x hldsupdatetool.bin");
	}
	test_file.close();



	
	test_file.open(".steamserverutil/steam");
	
	if( !test_file.is_open() )
	{
		cout << "\n\nFirst you have to accept the license agreement, show now?(y|n) ";
		cin >> choice;

		cout << "\n\n";
	
		if (choice == 'y')
		{
			system("cd .steamserverutil && ./hldsupdatetool.bin");
		}
		else
		{
			cout << "Aborting...\n";
			return 0;
		}	
			
	}
	
	

	test_file.close();
	test_file.open(".steamserverutil/steam");

	if( test_file.is_open())
	{
		cout << "found steam";

		test_file.close();
		
		
		bool exit=false;

		
		while(!exit)
		{
			unsigned int menu;
			cout << "\n\n\t**main menu**\n";
			cout << "1.  Install or update game server\n";
			cout << "2.  Start game server\n";
			cout << "3.  Currently running servers with \"screen\"\n";
			cout << "4.  Favorites\n";
			cout << "5.  Configure servers\n";
			cout << "6.  Update game servers (verifys all data!)\n";
			cout << "7.  Update Steam Linux Client (recommend for first use)\n";
			cout << "8.  Delete servers\n";
			cout << "9.  About\n";
			cout << "10. Exit\n";
			cout << " : ";
			cin >> menu;
			
			cin.ignore();

			switch (menu)
			{
				case 1: 	install();
						break;
				case 2: 	start();
						break;
				case 3:		screen_test();
						break;
				case 4: 	favorites();
						break;
				case 5:		config_server();
						break;
				case 6:		update_server();
						break;
				case 7:		update_client();
						break;
				case 8: 	delete_server();
						break;
				case 9:		about();
						break;
				case 10: 	exit=true;
						break;
				default:	cout << "Try again ;)";
						break;
			}

		}
	}
	else
	{
		never_happen();
		cout << "\nUnknown Error!\n";
		return 0;
	}


	return 1;

}
